User forums > Using Code::Blocks

Trying to create a DLL from Enet source code

(1/4) > >>

slenkar:
Hi Im trying to create a DLL from a library called Enet:
http://enet.bespin.org/

I got the source and compiled it into a static library,

then I created a new project:




--- Code: ---// dll.h
#ifdef __cplusplus
#define EXPORT extern "C" __declspec (dllexport)
#else
#define EXPORT __declspec (dllexport)
#endif

EXPORT int CALLBACK mymagicfunction(void);
--- End code ---


--- Code: ---#include <windows.h>
#include "dll.h"

EXPORT int CALLBACK mymagicfunction(void)
{
       enet_initialize();
}

--- End code ---

I told the IDE to use libenet.a as a linker. (the static library that I compiled)

the error message was:
ld.exe cannot find -lEnet

stahta01:
Turn on Compiler Logging and post the part of "Build Log" that contains the "ld.exe cannot find -lEnet" error and the 3 or 4 command lines right before it.

Steps to turn on Compiler Logging:
"Settings" -> "compiler debugger"
Change "Compiler Settings" to "Other Settings"
Set "Compiler Logging" to "Full Command Line"

slenkar:
thanks for helping:

--- Quote ---Project   : DLL Sample
Compiler  : GNU GCC Compiler (called directly)
Directory : C:\download\enet-1.0\enet-1.0\
--------------------------------------------------------------------------------
Switching to target: default
mingw32-g++.exe -shared  -Wl,--out-implib=libEnet.a -Wl,--dll    -LC:\Dev-Cpp\lib .objs\main.o   -o Enet.dll      -lEnet
C:\Dev-Cpp\bin\..\lib\gcc\mingw32\3.4.2\..\..\..\..\mingw32\bin\ld.exe: cannot find -lEnet
collect2: ld returned 1 exit status
Process terminated with status 1 (0 minutes, 1 seconds)
1 errors, 0 warnings
--- End quote ---

stahta01:
Where is Enet related to the project cbp file?

You need to add it to the search path in CB.

"Project" -> "Build Options"
Change to "Search Diretories"
Add the folder holding Enet library to linker tab.

Tim S

slenkar:
that worked THANKS


but now it is saying 'undefined reference to enet_initialize()'

I know for a fact that function/command is in the Enet source code.

Is just including the static library enough?

Navigation

[0] Message Index

[#] Next page

Go to full version