DevC++ linking question

Started by
2 comments, last by Joshnathan 19 years, 5 months ago
im only doing test programs which dont need more than one file and creating a project adds more than I care to have cluttering up my folders. Instead of creating a project and adding the libraries to project options, I would like to know if there is a way to tell the compiler to link certain libraries using code in a source file. I saw something in a tutorial but it didnt work.. #pragma comment(lib,"library.a") ..I think thats how it went. thanks -GamerCon
OS: WinXP HECOMPILER: DevC++ mingw32Programming since 10/3/2004 6:15:36 PMCurrent Project: An un-named MUDCompleted Projects:Tic-Tac-Toe (w32 console)PacMan (w32 console)Tetris (w32 console)Minesweeper (Allegro)BomberMan (Allegro)Chat Client (w32 console)
Advertisement
Dev-C++ does not have a #pragma for linking in libraries (though the Microsoft compiler does).

Go to Tools->Compiler Options. Under the Compiler tab, check Add these commands to the linker command line, and enter your libraries in there. (Type "-lfoo -lbar" to link to libfoo.a and libbar.a.)

However, note that these settings will apply to all the things you compile (not just the current file), so you may have to remove them later. If this is too bothersome, compare it to the bother of creating a project and see which one you like best.
I think there is something in the project settings to do the same thing, only for that one project, but it's been a while since I used dev-cpp
Create the file in a project, then push alt-p, or go Project -> Project Options. Then choose "Parameters" and add the library in the "linking" text box. This is how it works for me at least(and I use dev-c++ too).

Hope I helped out :D
Joshua
-----------------------------Sismondi GamesStarted c++ in October 2004...

This topic is closed to new replies.

Advertisement