Skip to main content
GameDev.net gamedev.net
🔒 Locked

DEV-C++ problems with malloc and new

Started by BigBoy Jan 11, 2003 at 1:30 PM 4 replies 8.2k views
Original Post
BigBoy
BigBoy
Hi, I have a few sample programs (NeHe''s OpenGL tutorials) which I have downloaded and tried to compile with DEV-C++ (version 4.9.5.0). However, it complains with: 115 C:\C++\OpenGL\test\test.cpp implicit declaration of function `int malloc(...)'' Upon substituting malloc with ... = new [some_size] and free with delete [] ..., the linker complains with [Linker error] undefined reference to `glTexParameteri@12'' Compiling the original code in a demo version of MSVC++ is fine. Can anyone shed some light on what I''m doing wrong, or maybe how to set up DEV-C++? Cheers, Jeroen
Cheers,Jeroen
Null and Void
Null and Void
You need to include the header stdlib.h (for malloc and free), and you need to link with the OpenGL libraries (by adding -lopengl32 to the linkage/compiler options in MinGW32 environments).

Alpha_ProgDes
Alpha_ProgDes
in case u didn''t know...
there was something on the website saying that the C++ ABI was changed (gcc 3.2) so the current libraries they have won''t work properly or at all. they have to change them (ie. the libraries) so they can comply with the compiler.
Beginner in Game Development?  Read here. And read here.  
BigBoy
BigBoy
quote:
Original post by Null and Void
You need to include the header stdlib.h (for malloc and free), and you need to link with the OpenGL libraries (by adding -lopengl32 to the linkage/compiler options in MinGW32 environments).




Yep, that pretty much fixed it. Thanks for your responses. I have a couple of questions on this then:

1. The code contains the line #pragma comment( lib, "opengl32.lib" ) . Is this a clue that the linker needs the extra option?

2. What does the line -lopengl32 actually do?

Although I''m not desperate for an answer, I would like to know why things need to be done, and start to understand the whole process a little more.

Cheers,
Jeroen


Cheers,Jeroen
barazor
barazor
1: this pragma is a msvc specific hint for including a lib, without having to put it into the project file

2: -lopengl32 is a compiler option for gcc that includes the opengl lib. lib filenames in gcc have a structure that looks like this:

libopengl32.a

this is what the opengl lib looked like. if you made your own custom library, and named it "mylib" it would create a "libmylib.a" file that you can place in the library directory, and add it to your program with the -lmylib switch

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.