views:

35

answers:

3

I made a program on mac osx using opengl and dynamically linking libpng. Im now trying to port it to windows. Whenever I try to compile and link my ported program in borland it gives me this error and about 10 more that are the same but with a different '_png_create_read_struct'

Error: Unresolved external '_png_create_read_struct' reference from C:\PROGRAMMING\PNGTEST.OBJ

I assume its because I have not properly set up libpng with Borland c++ 5.5.1 for win32. I've put png.h and pngconf.h into the include folder into C:\Borland\BCC55\Include and I have put libpng12.dll.a libpng13.a libpng13.dll.a libpng.a libpng.dll.a libpng12.def libpng.def libpng12.la and libpng.la into C:\Borland\BCC55\Lib (there is probably no need for them all, but as a noob im i have no idea which ones are needed and not). Do i need to put a libpng.obj file in there too? and if so how would i make/get one? I have tried using makefile.bc32 to set up libpng yet that gives me a missing separator error. Here is my command line options:

bcc32 -tW pngtest.cpp -lpng

I include png.h in my code. If anybody knows what I'm doing wrong or even a better way to load images with alpha that doesn't need libpng, or even a better compiler to get for windows that would be greatly greatly appreciated.

A: 

You're probably better off with the MinGW compiler than Borland. Borland is not well supported any longer.

You could also download DevC++ and see if it has a libpng package in its addon mechanism. DevC++ is an IDE that uses the MinGW C/C++ compiler.

That said, if you feel you must use BCC, you'll either have to a) Build libpng with Borland. This is the best solution if you're going to use borland. b) Use, I think, Impdef to create an import library from libpng.dll. You'll find impdef.exe or imp(something).exe in the borland bin directory. Note that some libraries will not work with impdef as there is static code linked to the dll that causes it to fail without the proper runtime.

JimR
Ok lets see if that works, otherwise i'll go with MinGW. Thanks!
A: 

First of all, I would not have "polluted" the BC55 installation with third-party libraries; it will make moving the project to other build environments much more difficult. It would have been better to place them in a folder within your project.

Secondly do you know that the export library you are attempting to link is built for BC55? The .a extension suggests a GNU library (Borland libraries conventionally use .lib extension), in which case it would not link with BC55 which uses a different object file format. If this is the case you will need to rebuild the library as you attempted to do, so I suggest that you should really be asking a question about the problem you had with doing just that. I wonder whether the makefile is written for Borland make or GNU make, since they have differing syntax?

The command line option -lpng might be correct for GCC (where it will link libpng.a), but is meaningless to BCC. The -l option merely passes the text that follows to the linker. The linker command line, requires that the complete name be passed, and if no extension is provided, .lib is added implicitly.

Clifford
Haha thanks, I really have no clue about most of this stuff. But the -tW thing actually makes it a windows gui program for me. When i compile other stuff with that same command line they just turn into the name of the cpp file with a .exe extension . I guess I'll keep trying to bulid libpng with borland and thank you very much for noticing the -lpng thing.