Author Topic: Linking and using other libs  (Read 5785 times)

Offline JessH

  • Single posting newcomer
  • *
  • Posts: 6
Linking and using other libs
« 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)
« Last Edit: July 29, 2010, 10:28:47 am by JessH »

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Linking and using other libs
« Reply #1 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" ?

Offline JessH

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linking and using other libs
« Reply #2 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 ...

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Linking and using other libs
« Reply #3 on: July 29, 2010, 11:42:30 am »
"Project -> Build options -> Linker settings -> Link libraries"

Offline JessH

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linking and using other libs
« Reply #4 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

Offline JessH

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linking and using other libs
« Reply #5 on: July 30, 2010, 12:17:44 pm »
Still doesn't work ... any other idea ?  :(

Offline JessH

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linking and using other libs
« Reply #6 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.

Online stahta01

  • Lives here!
  • ****
  • Posts: 7598
    • My Best Post
Re: Linking and using other libs
« Reply #7 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.
C Programmer working to learn more about C++ and Git.
On Windows 7 64 bit and Windows 10 64 bit.
--
When in doubt, read the CB WiKi FAQ. http://wiki.codeblocks.org

Offline JessH

  • Single posting newcomer
  • *
  • Posts: 6
Re: Linking and using other libs
« Reply #8 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

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Linking and using other libs
« Reply #9 on: August 05, 2010, 12:49:56 pm »
Do you have a project?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Linking and using other libs
« Reply #10 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.