Author Topic: MVCT 2003 linker errors  (Read 4062 times)

Elder

  • Guest
MVCT 2003 linker errors
« on: April 16, 2006, 03:12:50 pm »
Hello all.

I've tried to run project under CB for three weeks but all the time I meet with obstacles. I serched way to solve the problem and I find the reason of my problems but I cannot find solution. I've make everything as is in MVCT Wiki.
Problem is, when i tried to build project whitch is using some *.lib files I get LInker errors:
Code
Switching to target: default
Linking console executable: ..\bin\test.exe
main.obj : error LNK2019: unresolved external symbol _enet_initialize referenced in function _main
..\bin\test.exe : fatal error LNK1120: 1 unresolved externals
Process terminated with status 1 (0 minutes, 0 seconds)

Program code:
main.cpp:
Code: main.cpp
#include <iostream>
#include "enet/enet.h"

using namespace std;

int main(int argc,char *argv[])
{
if (enet_initialize() != 0)
    {
        std::cout << "An error occurred while initializing ENet.\n";
    return 1;
    }
return 0;
}
declaration of enet_initialize() is in "enet/enet.h" and body is in libenet.lib.

I know there is problem with linking libraries to every project. When I used MinGW I get the similar errors (undefined reference to sth). It's not first project returning errors. Some time ago I've _tired_ to work with Ogre3D but I've got the same problems with linking.

Pls help, I'm realy desperated! :?

PS. I've included libenet.lib to project and added it to Build->Compiler Options->Linker->Linker Libraries

Offline squizzz

  • Almost regular
  • **
  • Posts: 132
Re: MVCT 2003 linker errors
« Reply #1 on: April 16, 2006, 03:43:13 pm »
PS. I've included libenet.lib to project and added it to Build->Compiler Options->Linker->Linker Libraries

Hello,

This is wrong place to link libraries to a project - try Project->Build options->Linker->Linker Libraries instead.

It seems you are using old (RC2) version of Code::Blocks. In newer versions menus are reorganized a little bit, to avoid that kind of confusion.


« Last Edit: April 16, 2006, 05:44:09 pm by squizzz »
this space is for rent

Elder

  • Guest
Re: MVCT 2003 linker errors
« Reply #2 on: April 16, 2006, 05:25:18 pm »
Lib was added there too.

[edit]
if i switch compiler to MinGW i've got this error:
Code
ompiling: ..\src\main.cpp
Linking console executable: ..\bin\test.exe
.objs\src\main.obj:main.cpp:(.text+0x14f): undefined reference to `enet_initialize'
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 3 seconds)
Definitely problem is in linking this lib.
[/edit]
« Last Edit: April 16, 2006, 05:35:29 pm by Elder »

Offline Michael

  • Lives here!
  • ****
  • Posts: 1608
Re: MVCT 2003 linker errors
« Reply #3 on: April 16, 2006, 05:45:39 pm »
Hello,

What I will suggest you to do:

1) If you still use RC2, then try the latest nightly build.
2) Add the library(ies) path(es) to the Directories-->Linker (under Project-->Build options) and the library(ies) under Linker (under Project-->Build options).
3) Check that you include the header file(s) correctly too.

Best wishes,
Michael