User forums > Using Code::Blocks

Building other projects

<< < (2/2)

Decrius:

--- Quote from: Seronis on March 11, 2008, 11:23:51 pm ---Well it means exactly what it says.  The project you appear (by my understanding) to be talking about creates a library and does not create a program.  So you cant execute it.  Which is normal behaviour as libraries are not executable on their own.  So build your library,  then create a project that -uses- the library.

Sorry if im misunderstanding your problem but this it what it seems you are talking about.

--- End quote ---

Ah okay ^^. How easy, I never thought of that '-.-

Sorry then, thanks :)

Decrius:
Okay, I tried to build my own, but I got the classic 'undefined reference to ... ' error.

Sources:
The static library:

--- Code: ---int add_it_now(int i1, int i2)
{
    return i1 + i2;
}
--- End code ---

The executable:

--- Code: ---#include <iostream>

using namespace std;

int add_it_now(int, int);

int main()
{
    cout << add_it_now(5, 2) << endl;
    return 0;
}
--- End code ---

In the executable's project I added the right search directory for the linker and added the static library to the list. What could I possibly do wrong here?

Thanks in advance

dmoore:
try using the library name WITHOUT the file extension (.a, .lib or .dll)

Decrius:
In the list I added it without .a and without lib infront...or do you mean the filename of the static library?

EDIT:
Whatever else I do it cannot find the library, using the method I'm used to (libtestlib.a should be added to the left list as testlib and to the right list as -ltestlib) it _can_ find the library. Should the library contain a header file?

mattsnowboard:
I think you do need a header.  Though you did use

--- Code: ---int add_it_now(int, int);
--- End code ---
so that should suffice

Navigation

[0] Message Index

[*] Previous page

Go to full version