Author Topic: Two Projects in Workspace - problem with binding  (Read 2968 times)

Offline FCM

  • Multiple posting newcomer
  • *
  • Posts: 10
Two Projects in Workspace - problem with binding
« 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?

Offline stahta01

  • Lives here!
  • ****
  • Posts: 7582
    • My Best Post
Re: Two Projects in Workspace - problem with binding
« Reply #1 on: June 21, 2010, 04:04:14 pm »
Link to your library.

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 oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Two Projects in Workspace - problem with binding
« Reply #2 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 )

(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 FCM

  • Multiple posting newcomer
  • *
  • Posts: 10
Re: Two Projects in Workspace - problem with binding
« Reply #3 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. )
« Last Edit: June 21, 2010, 05:02:52 pm by FCM »

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Two Projects in Workspace - problem with binding
« Reply #4 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 :)
(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!]