Sign in to follow this  
GamerCon

DevC++ linking question

Recommended Posts

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

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this