Page 1 of 1
Creating UserLibraries: Linker Problem
Posted: Tue Dec 16, 2008 5:09 pm
by Violet
So far, so good, I created my UserLibrary using SDL and it compiles without Problems. But if I try to compile a PureBasic Code using those Functions, I get a Linker error.
pulsar.a(pulsar.o): In function `PB_InitPulsar':
pulsar.c:(.text+0xe): undefined reference to `SDL_Init'
pulsar.c:(.text+0x20): undefined reference to `SDL_GetVideoInfo'
collect2: ld gab 1 als Ende Status zurÃCEck
I don't understand that, I already linked the SDL stuff when compiling the C Source, or do I have to do that again now? How can I do that? I bet it's something simple...
Note: Operating System is Ubuntu 8.10 32-Bit
And by the way, how can I access PureBasic internal functions in my own UserLibraries (Maybe again something to link)?
Posted: Tue Dec 16, 2008 5:46 pm
by Fred
You need to add it at the linking stage as well (sdl-config --clibs).
Posted: Tue Dec 16, 2008 7:13 pm
by Violet
Like this? (Extraction of Makefile)
Code: Select all
gcc -c -DLINUX pulsar.c -lSDL -lSDL_image -lGL -lGLU `sdl-config --clibs`
I just ask because that didn't work that way. And I have to say that I am not so experienced in C yet. The Linking stuff is something new to learn...
Linker Problem
Posted: Mon Dec 22, 2008 4:15 pm
by Violet
*Bump*
Damn Telekom, didn't had Internet the last days...
I tried the stuff with sdl-config (Googled and so on) but that also doesn't work. When I try to compile the UserLibrary with the line of the makefile (calling gcc with parameters), it just waits for further input.
I examined the sdl-config script, and saw that "--clibs" is not a valid parameter, only "--libs" or "--cflags". But I tried every parameter. It always returns Include Paths, so I tried to compile the Library directly with those parameters. But never worked, as before, the linker problem.
Can anyone tell me how to do that? (Or a knowledge source for the whole linking stuff?)
Posted: Mon Dec 22, 2008 5:58 pm
by Fred
You are right it's: `sdl-config --libs`
It works for us (you can try putting an InitSprite() in your code, it should add it automatically).
Note: using '-c' is to create a object (.o)
The sdl-config needs to be specified at the linking stage (ie: when creating the final exe, not when creating a .o). If you do an user lib, your .Desc should look like this:
Code: Select all
; Langage used to code th library: ASM or C
;
C
; Number of windows DLL than the library need
;
1
`sdl-config --libs` -lgcc
; Library type (Can be OBJ or LIB)
;
LIB
; Number of PureBasic library needed by the library
;
0
; Help directory name
;
YourLibName
; Library functions (FunctionName, Arg1, Arg2, ...)
;
[Yourfunction here]
Posted: Mon Dec 22, 2008 9:39 pm
by Violet
Thanks, that worked!
I just didn't thought about that in the *.desc file, because there it's called "Windows DLLs needed by the library (and I am working on Linux).
Posted: Fri Dec 26, 2008 4:45 pm
by Violet
But isn't there any documentation about that whole thing anywhere? Something like an How-To? Because I am surely not the first one trying to make UserLibraries (compiling but not linking source code a.s.o.).
Because now I have the Problem, I get Linker Errors with the OpenGL Functions.
I already tried many ways to link OpenGL (When compiling C(++) Source with GNU GCC in Commandline these parameters are needed: "-lGL -lGLU") in the *.desc file, but won't work. And something similar like "sdl-config" for the OpenGL Library isn't there.

Re:
Posted: Mon Sep 28, 2009 10:07 am
by viiartz
Violet wrote:But isn't there any documentation about that whole thing anywhere? Something like an How-To? Because I am surely not the first one trying to make UserLibraries (compiling but not linking source code a.s.o.).
I would also like to find any information on compiling and specification of userlibs. I've been searching the forums for hours but don't seem to find anything on the subject.
Any help would be much appreciated.