Author Topic: link shared library to ConsoleApp  (Read 14286 times)

Offline grim_asle

  • Multiple posting newcomer
  • *
  • Posts: 14
link shared library to ConsoleApp
« on: October 17, 2013, 10:31:57 am »
Hi there,

this is another beginners-question...
how do i link a shared library (created with code::blocks as well) to my "console-application" ?
The error i get is "cannot find -lExamplelib.so"

I have set

build_options->linker-> linked libraries->libExamplelib.so ( that is indeed the full name of the Lib)
and I have deployed the path to this lib in the "search_directories".

The same worked with static linking, and i am confused by the linker, who is searching for another name than i provided in the settings.
Is this special and can someone tell me where to find general instructions how to link a shared library to my CA ?

Thanks so far,


ps: It does work invoking the compiler from my terminal with the corresponding options.
« Last Edit: October 17, 2013, 11:01:29 am by grim_asle »

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: link shared library to ConsoleApp
« Reply #1 on: October 17, 2013, 11:45:53 am »
have you set the right build target? On the left site of the build options. And it has to be activated near the build button...

Offline grim_asle

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: link shared library to ConsoleApp
« Reply #2 on: October 17, 2013, 01:26:35 pm »
Do you mean the "debug or release" option ?
I have checked that ... and I can't find any other options and settings etc. on the left of the Build-option pane. Maybe i'm blind ...

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: link shared library to ConsoleApp
« Reply #3 on: October 17, 2013, 04:21:02 pm »
have you checked if on both is the same under search directories and libraries?
post the full biuild log from the build log tab

greetings

Offline grim_asle

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: link shared library to ConsoleApp
« Reply #4 on: October 21, 2013, 08:40:52 am »
Hi again,

this is it:

Code
-------------- Build: Debug in gaslite_test ---------------

Linking console executable: bin/Debug/gaslite_test
/usr/bin/ld: cannot find -llibGASLITE_BWRS.so
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 0 seconds)
1 errors, 0 warnings
 


I guess it's not much, however.

greetings

Offline grim_asle

  • Multiple posting newcomer
  • *
  • Posts: 14
Re: link shared library to ConsoleApp
« Reply #5 on: October 21, 2013, 08:52:27 am »
Hi again, i think it worked now.

I' ll check what's the reason exactly, but maybe you can tell me :
does it play a role, wether I compile the shared lib in debug mode or not ??

Because i think that was the only change I made ... between my last effort and the (successful) one now ... i'm confused ...
However, I think this is solved ... can one mark a topic as "SOLVED" in this Forum ?

... another stupid question, hee ??

Offline BlueHazzard

  • Developer
  • Lives here!
  • *****
  • Posts: 3353
Re: link shared library to ConsoleApp
« Reply #6 on: October 21, 2013, 01:17:13 pm »
for the full build log, please make a rebuild, so we can see the command lines.
I' ll check what's the reason exactly, but maybe you can tell me :
does it play a role, wether I compile the shared lib in debug mode or not ??

well, if you set the library only in the Debug target it makes sense. In the "Build options" dialogue on the right you can choose where the buildoptions should take place, only in the debug target, only in the release or on both. So if you set the right library only in the Debug Target, you have to build the Debug target to get the right build....

here is more info:
http://wiki.codeblocks.org/index.php?title=The_build_process_of_Code::Blocks

greetings