Code::Blocks Forums

User forums => Help => Topic started by: FCM on June 21, 2010, 03:42:55 pm

Title: Two Projects in Workspace - problem with binding
Post by: FCM on June 21, 2010, 03:42:55 pm
I tried two projects in one workspace
1st of console type with source
Code
#include <iostream>
using namespace std;
int addint(const int& x, const int& y);
int main()
{
    cout << addint(10,20) << endl;
    return 0;
}

and 2nd of static lib type with source
Code
int addint(const int& x, const int& y)
{    return x+y;  }

and found that prototype of addint was not bound to its definition in static lib source.
Project dependencies was correct.
What else I have to do?
Title: Re: Two Projects in Workspace - problem with binding
Post by: stahta01 on June 21, 2010, 04:04:14 pm
Link to your library.

Tim S.
Title: Re: Two Projects in Workspace - problem with binding
Post by: oBFusCATed on June 21, 2010, 04:06:36 pm
stahta01 was faster :)

Read this: http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F

Then search the internet to understand what are static libraries and how to use them.

p.s.  probably you need to add the static lib to your linker options ( project -> build options -> linker settings -> add )

Title: Re: Two Projects in Workspace - problem with binding
Post by: FCM on June 21, 2010, 04:59:08 pm
probably you need to add the static lib to your linker options ( project -> build options -> linker settings -> add )

Thanks very much!

Then search the internet to understand what are static libraries and how to use them.

What are static libraries I know.
I used to Visual Studio where no additional steps is needed, if static lib project is in the same Solution as the project in which it is used - and it is reasonable. ( In other cases very useful is directive #pragma comment(lib, "path_to_static_lib") - without any project properties tuning. )
Title: Re: Two Projects in Workspace - problem with binding
Post by: oBFusCATed on June 21, 2010, 05:23:03 pm
CB doesn't add the libs automatically at the moment, because it is hard to be implemented for all compilers CB supports.

Not sure if there is such pragma for gcc, but they are a bit ugly :)