News:

As usual while waiting for the next release - don't forget to check the nightly builds in the forum.

Main Menu

Building other projects

Started by Decrius, March 10, 2008, 09:35:29 PM

Previous topic - Next topic

Decrius

So, some projects do not provide plug'n'play files (pre-build library files) to work with (like ENet), so I have to build it myself. Often it gives me lots of errors because CodeBlocks is slightly different then VisualStudio (atleast, the compilers they use). This time not, so far...

What I get: Please select a host to "run" a library...
I searched on this forum, and someone said "go to this config window", and there I could choose a "host executable". What IS a host executable? What does it DO? And more important, which .exe should I choose, as its obviously not notepad.exe

I didn't got that to work, though it DID create a .a file, I put it in lib/ and linked to it in my project, getting lots of undefined reference errors, so I guess the .a file is not good =/

Any help on this one would be much appreciated :)
Decrius
Check out my website: [url="http://www.daevius.com"]http://www.daevius.com[/url]

Decrius

Nobody knows? How could this be so difficult/barely documentated anyways? It's quite important as most libraries don't come with the plug'n'play libraries.
Check out my website: [url="http://www.daevius.com"]http://www.daevius.com[/url]

dmoore

I have no idea what you mean by plug'n'play library (a self executing library?). Irrespective of IDE, you won't to be able to "run" or "debug" a library directly, but you can run or debug a program or process that calls into your library (and, if debugging, step through the library routines).

you should be able to link to any library binaries that you build (.dll/.a) without errors. try switching on compiler logging so that you can see the full command lines being passed to gcc. try those issuing those same commands at the command line yourself.

other people might be able to help if you provide more info on the errors and the project structure
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

Decrius

I did: I cannot build my own library files.

With plugnplay I mean: you put the libraries in a directory, link to them and you got it running. Some projects do not provide those libraries but only its sources, therefore I need to build it myself. "You need a host exectuable to "run" a library..." thats the error I get, even if I start my own library project =/.
Check out my website: [url="http://www.daevius.com"]http://www.daevius.com[/url]

Seronis

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.

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.

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

Sorry then, thanks :)
Check out my website: [url="http://www.daevius.com"]http://www.daevius.com[/url]

Decrius

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

Sources:
The static library:
int add_it_now(int i1, int i2)
{
    return i1 + i2;
}


The executable:
#include <iostream>

using namespace std;

int add_it_now(int, int);

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


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
Check out my website: [url="http://www.daevius.com"]http://www.daevius.com[/url]

dmoore

try using the library name WITHOUT the file extension (.a, .lib or .dll)
Python plugins: [url="https://github.com/spillz/codeblocks-python"]https://github.com/spillz/codeblocks-python[/url]
Code::Blocks Daily Builds -- Ubuntu PPA: [url="https://launchpad.net/~damien-moore/+archive/codeblocks"]https://launchpad.net/~damien-moore/+archive/codeblocks[/url]

Decrius

#8
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?
Check out my website: [url="http://www.daevius.com"]http://www.daevius.com[/url]

mattsnowboard

I think you do need a header.  Though you did use
int add_it_now(int, int);
so that should suffice