Author Topic: Building other projects  (Read 4862 times)

Offline Decrius

  • Multiple posting newcomer
  • *
  • Posts: 81
    • Daevius
Building other projects
« on: March 10, 2008, 09:35:29 pm »
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: http://www.daevius.com

Offline Decrius

  • Multiple posting newcomer
  • *
  • Posts: 81
    • Daevius
Re: Building other projects
« Reply #1 on: March 11, 2008, 06:46:51 pm »
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: http://www.daevius.com

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Building other projects
« Reply #2 on: March 11, 2008, 07:28:26 pm »
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

Offline Decrius

  • Multiple posting newcomer
  • *
  • Posts: 81
    • Daevius
Re: Building other projects
« Reply #3 on: March 11, 2008, 09:13:58 pm »
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: http://www.daevius.com

Offline Seronis

  • Almost regular
  • **
  • Posts: 197
Re: Building other projects
« Reply #4 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.

Offline Decrius

  • Multiple posting newcomer
  • *
  • Posts: 81
    • Daevius
Re: Building other projects
« Reply #5 on: March 12, 2008, 03:28:21 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: http://www.daevius.com

Offline Decrius

  • Multiple posting newcomer
  • *
  • Posts: 81
    • Daevius
Re: Building other projects
« Reply #6 on: March 12, 2008, 09:19:18 pm »
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;
}

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;
}

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: http://www.daevius.com

Offline dmoore

  • Developer
  • Lives here!
  • *****
  • Posts: 1576
Re: Building other projects
« Reply #7 on: March 12, 2008, 10:50:40 pm »
try using the library name WITHOUT the file extension (.a, .lib or .dll)

Offline Decrius

  • Multiple posting newcomer
  • *
  • Posts: 81
    • Daevius
Re: Building other projects
« Reply #8 on: March 12, 2008, 11:04:27 pm »
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?
« Last Edit: March 12, 2008, 11:08:27 pm by Decrius »
Check out my website: http://www.daevius.com

Offline mattsnowboard

  • Single posting newcomer
  • *
  • Posts: 6
Re: Building other projects
« Reply #9 on: March 13, 2008, 09:33:37 pm »
I think you do need a header.  Though you did use
Code
int add_it_now(int, int);
so that should suffice