Code::Blocks Forums

User forums => Using Code::Blocks => Topic started by: JessH on July 29, 2010, 10:21:46 am

Title: Linking and using other libs
Post by: JessH on July 29, 2010, 10:21:46 am
Hi guys I'm new to c++ programming and after a few days trying different IDEs I've chosen C::B.

I have been writing some simple stuff and it was all ok until i needed to use some other libraries. I guess it has to do with setting the path or something like that. I tried this :

http://wiki.codeblocks.org/index.php?title=FAQ#Q:_I_would_like_to_compile_a_project_using_some_non-standard_libraries._How_can_I_indicate_to_CodeBlocks_that_these_libraries_and_include_files_exist.3F

but it doesn't seem to work. I did that and added a lot of folders, I even tried with adding all the folders in the tree one by one, but when I try to compile my program C::B doesn't find the functions that I call. The error says "undefined reference to XXfuncion ".

I also tried searching in the forum but I got nothing :( , I hope I posted this in the right place and wish you can help me ^^

Edit :I'm using suse and C::B 10.05 (Debugger 0.3 compiler 0.99)
Title: Re: Linking and using other libs
Post by: Jenna on July 29, 2010, 10:30:15 am
Did you also add the librar(y)(ies) to the "Link libraries:" in the projects/targets "Linker settings" ?
Title: Re: Linking and using other libs
Post by: JessH on July 29, 2010, 10:50:04 am
I can't find that option. If you mean settings>debugger and compiler>linker settings tab , yes I did.

I'm trying to fin that projects/target option now ...
Title: Re: Linking and using other libs
Post by: Jenna on July 29, 2010, 11:42:30 am
"Project -> Build options -> Linker settings -> Link libraries"
Title: Re: Linking and using other libs
Post by: JessH on July 29, 2010, 12:01:41 pm
OK I found it thanks. It was empty. Though I don't have a .a .so .lib or so to add , I installed the library from source  and I got the .cpp .hpp .o ... is there any other way ?

In Konsole when I g++ specifying -l and the library name it works fine
Title: Re: Linking and using other libs
Post by: JessH on July 30, 2010, 12:17:44 pm
Still doesn't work ... any other idea ?  :(
Title: Re: Linking and using other libs
Post by: JessH on August 04, 2010, 09:02:49 am
Thanks for the help ....

Anyway i solved this :

Settings > Compiler and debugger > global compiler settings > linker settings
In 'link libraries' press 'add' and type the name of the library , in my case it was curl and curlpp.
Title: Re: Linking and using other libs
Post by: stahta01 on August 04, 2010, 04:03:45 pm
Thanks for the help ....

Anyway i solved this :

Settings > Compiler and debugger > global compiler settings > linker settings
In 'link libraries' press 'add' and type the name of the library , in my case it was curl and curlpp.

The above is an example of the wrong way to do things; sometimes in the future this person
will asked us why is the libraries curl and curlpp always being linked in my new projects.

Tim S.
Title: Re: Linking and using other libs
Post by: JessH on August 05, 2010, 11:28:33 am
Hi Tim, if that is the wrong way to do it why don't you show me the right one ? I posted several times that jens' solution didn't work and still got no help. So please if you know the answer post it for future users and stop being so overbearing  :wink: no offence
Title: Re: Linking and using other libs
Post by: oBFusCATed on August 05, 2010, 12:49:56 pm
Do you have a project?
Title: Re: Linking and using other libs
Post by: Jenna on August 06, 2010, 12:05:02 pm
If you do not have a project, my solution will not work, and using the global compiler settings is all you can do, even if it will probably lead to errors later as Tim wrote.

My solution does exactly the same as using global settings, that are common to all projects and files, but on project level.