Unresolved external _SDL_Init

I am trying to use SDL 2.0.3 with C++ Builder XE6 so used IMPLIB to convert the dll to a lib and added it to my project. Then wrote a little program that just calls SDL_Init() and upon linking I get above error. Figuring this had to do with the (in)famous Microsoft-Borland underscore problem I also tried the -a option for IMPLIB as well as -aa but the error remains. I also get a duplicate symbol warning for _SDL_Log btw.

Does anyone know what I am doing wrong?

SDL_Init takes an argument, did you pass an argument?On Mon, May 12, 2014 at 6:08 AM, Mike Versteeg wrote:

I am trying to use SDL 2.0.3 with C++ Builder XE6 so used IMPLIB to convert
the dll to a lib and added it to my project. Then wrote a little program
that just calls SDL_Init() and upon linking I get above error. Figuring this
had to do with the (in)famous Microsoft-Borland underscore problem I also
tried the -a option for IMPLIB as well as -aa but the error remains. I also
get a duplicate symbol warning for _SDL_Log btw.

Does anyone know what I am doing wrong?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Yes, My single line of code is

Code:
SDL_Init(SDL_INIT_EVERYTHING)

But please note I am not getting any compiler errors, just the linker error. I have never had any issues using MSVC dll’s (other than the underscore problem) so not sure why this is not working.

Yeah, I know it is a linker error. I am not so much a windows person so I
am not positive but iirc the MSVC symbols for functions are always C++
style and are name mangled (although the header should not have been
letting SDL_init through, I was just verifying). I thought it would be
?sdl_init_i in MSVC (regardless of being C code).On Mon, May 12, 2014 at 7:27 AM, Mike Versteeg wrote:

Yes, My single line of code is

Code:

SDL_Init(SDL_INIT_EVERYTHING)

But please note I am not getting any compiler errors, just the linker
error. I have never had any issues using MSVC dll’s (other than the
underscore problem) so not sure why this is not working.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Keep in mind I am likely way wrong.On Mon, May 12, 2014 at 7:36 AM, Andre D <@Andre_D> wrote:

Yeah, I know it is a linker error. I am not so much a windows person so I
am not positive but iirc the MSVC symbols for functions are always C++
style and are name mangled (although the header should not have been
letting SDL_init through, I was just verifying). I thought it would be
?sdl_init_i in MSVC (regardless of being C code).

On Mon, May 12, 2014 at 7:27 AM, Mike Versteeg wrote:

Yes, My single line of code is

Code:

SDL_Init(SDL_INIT_EVERYTHING)

But please note I am not getting any compiler errors, just the linker
error. I have never had any issues using MSVC dll’s (other than the
underscore problem) so not sure why this is not working.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Nevermind, look like they disable C++ name mangling when extern “C” is
used. Ignore me, I am crazyOn Mon, May 12, 2014 at 7:37 AM, Andre D <@Andre_D> wrote:

Keep in mind I am likely way wrong.

On Mon, May 12, 2014 at 7:36 AM, Andre D <@Andre_D> wrote:

Yeah, I know it is a linker error. I am not so much a windows person so
I am not positive but iirc the MSVC symbols for functions are always C++
style and are name mangled (although the header should not have been
letting SDL_init through, I was just verifying). I thought it would be
?sdl_init_i in MSVC (regardless of being C code).

On Mon, May 12, 2014 at 7:27 AM, Mike Versteeg wrote:

Yes, My single line of code is

Code:

SDL_Init(SDL_INIT_EVERYTHING)

But please note I am not getting any compiler errors, just the linker
error. I have never had any issues using MSVC dll’s (other than the
underscore problem) so not sure why this is not working.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

Meanwhile I have examined the created lib and _SDL_Init is there, so I am at a complete loss why the linker does not see it. Is there anything else I should be aware of?

Found the problem: my (new) compiler has a very weird default setting causing it not to use the lib I asked it to use. Let the testing begin! :slight_smile: