Qbasicnews.com

Full Version: Dev C++ Wont Link!
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Im just finding out the joys and tortures of splitting my c++ code. cause I usually just had one source file, devc++ 4 would just compile and link at the same time. now im using a project (blank). it compiles(no errors), and brings up a window saying something like 'g++: -lalleg not used cause prog not linked'. In the past just hitting compile again linked it, but it just wont link no matter how many times i compile now Cry im using allegro and (as previously stated) dev c++ 4 on Win95.
In most IDEs, when you handle a project you must specify which non standard libraries should be linked along with your OBJs. To do this, there is usually a "libraries" option in the "projects" menu. There you should load your libraries (i.e. alleg for allegro 'cause allegro is on liballeg.a or alleg.lib). I don't use DevC IDE, so I can't help you more than this.

EDIT: I checked "TFM" which comes with Allegro (mingw32.txt, which is the compiler you're using along with Dev C++), and it explains how to do it (remember: everything comes in TFM - lol):

Quote:A simple example on how to create a little program with Dev-C++:

Launch Dev-C++ and create a new project (File/New Project). Select
"Windows Application", then click on the "Ok" button. Name your
project and give associate it to a new file. You should now see a
sample code in a window. Close that window since you won't be
needing it (Allegro is much simpler to use than this). Create a
new file (File/New Source File), then write a small Allegro
program. You can inspire yourself by the Allegro examples if you
wish. Here's a small program you can type to see if everything
worked until now:

Code:
#include <allegro.h>

      int main() {
         allegro_init();
         allegro_message("Hello World!");
         return 0;
      }
      END_OF_MAIN();

You now need to tell Dev-C++ that you'd like to make a program that
uses Allegro. For that, go in the Project Options screen
(Project/Project Options menu), then enter -lalleg (or -lalld for
the debug mode) in the box under 'Further object file or linker
options'.

Compile your project! Simply click on the green check mark on
your Dev-C++ toolbar. Correct any syntax errors in your code,
then click on "Execute" to run the program. If all worked
you will see a message box pop up with "Hello World" inside of it.

Hope this helps Smile
I might be stupid but im not a fool nat. :lol: The green check that compiles you project normally compiles and links, but for some reason wont with this one. It compiles fine, brings up the compile results and then another window saying it didnt need the '-lalleg' ive got in the linker options cause it didnt link. now why wont it link!?
Do you just have a blank project without any source files? I think that would screw up some of Allegro's stuff like the magic main macros and suchlike... maybe some source would be helpful.
Quote:I might be stupid but im not a fool nat.

I never intended to call you either stupid or fool.

It's strange. I can't help you further until I download the whole thing. I'll have some spare time on Sunday, can you point me on where to download DevC++ and the compiler?
im using dev c++4 found at http://www.bloodshed.net. The latest version is 5 but there were alot of bugs when I got it. If you download the complete package (which i recommend, it will be useful to have) the mingw(i think) compiler is included.

and i will reiterate for those of you whop still believe i dont walk upright. Im not a fool, just a tad on the slow side!!! Of course ive got soure files, how else would split my project up??? :roll:
blank refers to the type of project (windows, dll, console or BLANK are avalible)
Quote:im using dev c++4 found at http://www.bloodshed.net. The latest version is 5 but there were alot of bugs when I got it.

5 is not out, its a beta still, but let me say this:

Beta 5 is so much better than 4 thats it's not even funny. Ive never had a memory leak with 5, compared to the hundreds in 4, its infinietly more stable, and has hundreds of other perks. If it wernt for project size limitations, i would never go back to 4 AGAIN!

And with the info your giving us there is no way we can help you, that is a very generic error, can we have some errors(as in compiler errors), your compile log, maybe a screen shot, or even source code?
There are no compile errors! It compiles, then brings up a window which has the a message something like this..
"g++: -lalleg not used because file was not linked"
It compiles without any problems, thats why I havnt a clue WTF is happening.

Ill try post my source and a screenie of the error when i get a chance but heres an outline of the files.

main.cpp: has the main function and some filehandling stuff.
main.h: has the gloabals
graphics.cpp: has some drawing stuff in it
graphics.h has the function defs for graphics.cpp eg:

#ifndef _graphics_H
#define _graphics_H
void funcs()...

#endif

EDIT:
+- 3 hours later......

Ive been playing around in dev c++ and found that there is a 'static linked allegro project'. turns out that this worked perfectly. well, off to try cut down on those globals now......