hi, I have several questions as to the linkage of libraries(and other source
files) in Dev C++ .
They all arise out of daily practices:
1.I am studying many OpenGl tutorials and trying to
rewrite them in my way. I find it tedious using Dev C++ Projects.
Here is what I do: I create a project in the programe directory and place all
supporting
thrid-party source files and headers in it. When studying demos and tutorials,
I copy one into the working folder from other
folder,and
load it into the dev-project.After that, I just delete it. When writing
my own files, I create one in the working directory.After running, I have to
transfer it to other places to "store" it. What
is more, as time is going on, the unwanted object files grow, so I have to
delete them from time to time.
What do I want? Simple! I want clean and tidy compilation: One excutable per
source file. I know how to manually compile a
hello-world
console application. Is it:gcc hello.c -o hello.exe? But it is not the case
when it comes to linkage of libraries and other
source files. I badly need a detailed tutorial on this. What is more, I am
using freeglut which comes with a MicroSoft .lib
So I have to specify its full path in the linker options. How should we do if
using command line compilation?
A FAQ is that many people failed to link libopengl.a .....to their projects and asked why.
This should not surprise us since in VC++ this is not an issue. In the
gl.h,glu.h,glut.h, there are some #pragma
telling the compiler to load respective libs. Is it possible to do so in Dev
C++? Since MinGW can automatically load
C/C++ standard libraries and Win32 API libs when including headers such as
"stdio.h","windows.h", why can't this
magic be applied to OpenGL libraries?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Dev-C++ is just and IDE. If you want to know how to drive teh tools from the
command line, look at the relevent GNU manuals for GCC and Binutils.
Your question is completely unclear, and waffley, I am not entirely sure what
you want, or why you believe a command line build would be simpler.
When Dev-C++ manages a build, it generates a makefile which is then processed
by GNU make (another manual for you!). The makefile.win that it generates can
be executed from the command line, and you might look at its content to see
how a multi-component build is performed (it required multiple command lines,
and that is what make issues).
Another way to see how the toolchain is invoked is simply to look at the
output in Dev-C++'s Compile Log windows, where all the commands issued in the
build are shown (use Rebuild All to see all commands).
Finally if this is just about repetitively setting up projects, why don't you
create a new project template? The template files (in c:\dev-c++\templates)
are plain text, and the mechanism by which they work is fairly
straightforward, adding your own is not that difficult.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi, Wayne, I read it but could not find what concerns me.
In VC++, there is #pragma comment (lib, "opengl32.lib")
I am wondering whether there is similiar functinality in DevC++?
Thank you!
Hi,cpns. Why was I "waffing"? I got the Red Book source code which
contains over 60 .c files. I don't want to compile them one by one using a
project. The best solution may be using makefile.
I typed make -f makefile.win all in the command prompt,but there is an error
message which says: makefile.win:6: *** missing separator.Stop
What should I do now? Thank you!
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
You ought to know that you cannot actually link Microsoft .lib files using
MinGW/GCC 3.4.x.
Why don't you use VC++ is toy are familiar with that already?
I cannot tell you why the makfile failed at line 6 without seeing line 6 of
the makefile! However to build from the command line, you do need to add c
:\dev-cpp\bin to the PATH environment variable first.
Regarding the #pragma, GCC does not use that method of instructing teh linker.
Libraries are passed to the linker via the command line. But that remains
academic if you are trying to use an MS library.
I described the question as "waffley" because you wrote a lot, and I
still had no idea what your problem or question really was, or what the work-
flow you described actually is, or if it makes any sense.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello, Clifford, Thanks for your invaluable suggestions.
My real problem is to run the makefile. The environment variable has already
beeb set correctly. The makefile(one is Makefile, the other is called
makefile.win) comes with the source-code package. It contains over 60 C source
files.
How to run the makefile ? I typed " make -f makefile.win all"
and it did not work.
Now I will copy the contents of the makefiles , and I hope won't mind. :)
thank you very much.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
But this is not a Dev-C++ generated makefile. If this is a custom makefile,
I'd avoid calling it makefile.win, in case it gets overwritten by Dev-C++'s
generated file.
Post the content with code mark-up to preserve the formatting and prevent the
lines from being merged. (Of course assuming SourceForge's flaky mark-down
implementation does not screw it up for you!)
Omitting comments merely makes it impossible for me to identify which is line
6 which the error message complained about. Why are you making this more
difficult than it has to be?
You have a rule to make a .obj from an .c and another to make a .exe from a .c
- i.e. two rules for one dependency type.
The .c to .obj rule will invoke whatever is defined as CC, but its definition
is not included.
You have a mix of .o and .obj file extensions. In GCC the convention is to use
.o for object files.
You have posted two different makefiles (makefile.win and makefile), which one
are you actually using? The second one looks like it was intended for *nix
since the target executables have no extension.
Perhaps you need the ?
It remains entirely unclear to me what it is you are trying to do.
Hi, Clifford.
I am having great difficulty in running makefile, let alone that I am able to
understand or write a correct makefie. Makefile was designed to make life
easier, Alas, It has inflicted so much annoyance and frustration upon me.
I think I should stick to using the project.,just to make life easier and do
what should be prioritized.
Thank you again for your continued commitment to the forum and great help for
all of us.God bless you,Clifford and Wayne.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
One more thing, I think I may be incompetent in getting myself understood.
Here is My problem:
I downloaded the source code for the OpenGL Red Book. The source code comes
with more than sixty .c source files. I want to compile them.
That is I want to get 60 respective excutables. It is a bit tedius to compile
by creating a project. So I want to use the makefiles which come with it. I
have problems in running the makefiles. Error message pop up(stated above).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Looking at you makefile.win again, it si sobvious that this is not intended to
work with GCC, for starters it applies a command line option -nologo, which is
not a GCC command option.
And you have still not addresses my point about opengl32.lib is not a GNU
library. Continuing with this is pointless without sorrting out the correct
toolchain.
Why are you attempting to use Dev-C++ at all for this task?
Why have you not provided a linke to the source project you are attempting to
build? What tools do they suggest the project is intended for? You assume a
lot in thinking that I have any idea what "OpenGL Red Book" is. Of
course I have Googled it and am perhaps a little more clued up.
I have looked at the makefiles you posted elsewhere, and line 6 of
makefile.win (the line make.exe was reporting as an error) is:
!include <ntwin32.mak>
That was 'lost' in your original post of the text because you failed to use
code mark-up as I suggested. Seeing that makes the problem rather obvious;
this is not a GNU makefile, but rather a a Microsoft Nmake makefile. This as
well as the fact that linking opengl32.lib is doomed to failure using MinGW
suggests that you should do as I suggested earlier and use the Microsoft VC++
toolchain to build this code. It comes with the nmake.exe utility so you can
build it form teh command line, or use it in a "Makefile Project"
within the IDE.
The makefile that is just called "makefile" is a GNU makefile, but
it is targeted at *nix. That is however probably your best starting point if
you insist on using MinGW/GCC. How to get the necessary libraries that it
links in MinGW compatible versions is explained in the link that Wayne
originally pointed you to and which you seemed to think was not helpful. No
hi, I have several questions as to the linkage of libraries(and other source
files) in Dev C++ .
They all arise out of daily practices:
1.I am studying many OpenGl tutorials and trying to
rewrite them in my way. I find it tedious using Dev C++ Projects.
Here is what I do: I create a project in the programe directory and place all
supporting
thrid-party source files and headers in it. When studying demos and tutorials,
I copy one into the working folder from other
folder,and
load it into the dev-project.After that, I just delete it. When writing
my own files, I create one in the working directory.After running, I have to
transfer it to other places to "store" it. What
is more, as time is going on, the unwanted object files grow, so I have to
delete them from time to time.
What do I want? Simple! I want clean and tidy compilation: One excutable per
source file. I know how to manually compile a
hello-world
console application. Is it:gcc hello.c -o hello.exe? But it is not the case
when it comes to linkage of libraries and other
source files. I badly need a detailed tutorial on this. What is more, I am
using freeglut which comes with a MicroSoft .lib
So I have to specify its full path in the linker options. How should we do if
using command line compilation?
This should not surprise us since in VC++ this is not an issue. In the
gl.h,glu.h,glut.h, there are some #pragma
telling the compiler to load respective libs. Is it possible to do so in Dev
C++? Since MinGW can automatically load
C/C++ standard libraries and Win32 API libs when including headers such as
"stdio.h","windows.h", why can't this
magic be applied to OpenGL libraries?
Did you read the section in the "Pleaser Read" thread covering the
compile log, includinge headers and linking libraries?
Dev-C++ is just and IDE. If you want to know how to drive teh tools from the
command line, look at the relevent GNU manuals for GCC and Binutils.
Your question is completely unclear, and waffley, I am not entirely sure what
you want, or why you believe a command line build would be simpler.
When Dev-C++ manages a build, it generates a makefile which is then processed
by GNU make (another manual for you!). The makefile.win that it generates can
be executed from the command line, and you might look at its content to see
how a multi-component build is performed (it required multiple command lines,
and that is what make issues).
Another way to see how the toolchain is invoked is simply to look at the
output in Dev-C++'s Compile Log windows, where all the commands issued in the
build are shown (use Rebuild All to see all commands).
Finally if this is just about repetitively setting up projects, why don't you
create a new project template? The template files (in c:\dev-c++\templates)
are plain text, and the mechanism by which they work is fairly
straightforward, adding your own is not that difficult.
Hi, Wayne, I read it but could not find what concerns me.
In VC++, there is #pragma comment (lib, "opengl32.lib")
I am wondering whether there is similiar functinality in DevC++?
Thank you!
Hi,cpns. Why was I "waffing"? I got the Red Book source code which
contains over 60 .c files. I don't want to compile them one by one using a
project. The best solution may be using makefile.
I typed make -f makefile.win all in the command prompt,but there is an error
message which says: makefile.win:6: *** missing separator.Stop
What should I do now? Thank you!
Sorry , I should have said "Hi, Clifford"!
Sorry for my rudeness
You ought to know that you cannot actually link Microsoft .lib files using
MinGW/GCC 3.4.x.
Why don't you use VC++ is toy are familiar with that already?
I cannot tell you why the makfile failed at line 6 without seeing line 6 of
the makefile! However to build from the command line, you do need to add c
:\dev-cpp\bin to the PATH environment variable first.
Regarding the #pragma, GCC does not use that method of instructing teh linker.
Libraries are passed to the linker via the command line. But that remains
academic if you are trying to use an MS library.
I described the question as "waffley" because you wrote a lot, and I
still had no idea what your problem or question really was, or what the work-
flow you described actually is, or if it makes any sense.
Hello, Clifford, Thanks for your invaluable suggestions.
My real problem is to run the makefile. The environment variable has already
beeb set correctly. The makefile(one is Makefile, the other is called
makefile.win) comes with the source-code package. It contains over 60 C source
files.
How to run the makefile ? I typed " make -f makefile.win all"
and it did not work.
Now I will copy the contents of the makefiles , and I hope won't mind. :)
thank you very much.
FIRST COMES THE MAKEFILE.WIN
(comments prefixed with ## are omitted)
!include <ntwin32.mak>
CFLAGS = $(cdebug) -DWIN32 -nologo -w
LIBS = glut.lib glu32.lib opengl32.lib $(guilibs)
TARGETS = \
aaindex.exe aargb.exe accanti.exe accpersp.exe alpha3D.exe \
alpha.exe bezcurve.exe bezmesh.exe bezsurf.exe blendeqn.exe \
checker.exe clip.exe colormat.exe combiner.exe cubemap.exe \
cube.exe dof.exe double.exe drawf.exe feedback.exe \
fogcoord.exe fogindex.exe fog.exe font.exe hello.exe \
image.exe light.exe lines.exe list.exe material.exe \
mipmap.exe model.exe movelight.exe multisamp.exe multitex.exe \
mvarray.exe pickdepth.exe picksquare.exe planet.exe pointp.exe \
polyoff.exe polys.exe quadric.exe robot.exe scene.exe \
select.exe shadowmap.exe smooth.exe stencil.exe stroke \
surface.exe surfpoints.exe teapots.exe tesswind.exe tess.exe \
texbind.exe texgen.exe texprox.exe texsub.exe texture3d.exe \
texturesurf.exe torus.exe trim.exe unproject.exe varray.exe \
wrap.exe
IMAGING_SUBSET = colormatrix.exe colortable.exe convolution.exe \
histogram.exe minmax.exe blendeqn.exe
all : $(EXES) $(IMAGING_SUBSET)
.c.exe:
$(CC) $(CFLAGS) -c $<
$(link) $(linkdebug) -nologo -out:$@ $*.obj $(LIBS)
.c.obj:
$(CC) $(CFLAGS) -c $<
colormatrix.exe : colormatrix.obj readImage.obj
$(link) $(linkdebug) -nologo -out:$@ $*.obj $(LIBS)
colortable.exe : colortable.obj readImage.obj
$(link) $(linkdebug) -nologo -out:$@ $*.obj $(LIBS)
convolution.exe : convolution.obj readImage.obj
$(link) $(linkdebug) -nologo -out:$@ $*.obj $(LIBS)
histogram.exe : histogram.obj readImage.obj
$(link) $(linkdebug) -nologo -out:$@ $*.obj $(LIBS)
minmax.exe : minmax.obj readImage.obj
$(link) $(linkdebug) -nologo -out:$@ $*.obj $(LIBS)
blendeqn.exe : blendeqn.obj readImage.obj
$(link) $(linkdebug) -nologo -out:$@ $*.obj $(LIBS)
clean:
rm -f .exe .obj *.pdb
Now THE MAKEFILE
TARGETS = \
aaindex aargb accanti accpersp alpha3D \
alpha bezcurve bezmesh bezsurf blendeqn \
checker clip colormat combiner cubemap \
cube dof double drawf feedback \
fogcoord fogindex fog font hello \
image light lines list material \
mipmap model movelight multisamp multitex \
mvarray pickdepth picksquare planet pointp \
polyoff polys quadric robot scene \
select shadowmap smooth stencil stroke \
surface surfpoints teapots tesswind tess \
texbind texgen texprox texsub texture3d \
texturesurf torus trim unproject varray \
wrap
IMAGING_SUBSET = colormatrix colortable convolution histogram minmax blendeqn
TOP = .
GLUT = -lglut
LLDLIBS = $(GLUT) -lGLU -lGL -lXmu -lXext -lX11 -lm
targets : $(TARGETS)
default: targets $(IMAGING_SUBSET)
all: default
.c.o:
cc -c -I/usr/include -I$(TOP) $<
$(TARGETS): $$@.o
cc $@.o $(LLDLIBS) -o $@
$(IMAGING_SUBSET) : $$@.o readImage.o
cc $@.o readImage.o $(LLDLIBS) -o $@
But this is not a Dev-C++ generated makefile. If this is a custom makefile,
I'd avoid calling it makefile.win, in case it gets overwritten by Dev-C++'s
generated file.
Post the content with code mark-up to preserve the formatting and prevent the
lines from being merged. (Of course assuming SourceForge's flaky mark-down
implementation does not screw it up for you!)
Omitting comments merely makes it impossible for me to identify which is line
6 which the error message complained about. Why are you making this more
difficult than it has to be?
You have a rule to make a .obj from an .c and another to make a .exe from a .c
- i.e. two rules for one dependency type.
The .c to .obj rule will invoke whatever is defined as CC, but its definition
is not included.
You have a mix of .o and .obj file extensions. In GCC the convention is to use
.o for object files.
You have posted two different makefiles (makefile.win and makefile), which one
are you actually using? The second one looks like it was intended for *nix
since the target executables have no extension.
Perhaps you need the ?
Hi, Clifford.
I am having great difficulty in running makefile, let alone that I am able to
understand or write a correct makefie. Makefile was designed to make life
easier, Alas, It has inflicted so much annoyance and frustration upon me.
I think I should stick to using the project.,just to make life easier and do
what should be prioritized.
Thank you again for your continued commitment to the forum and great help for
all of us.God bless you,Clifford and Wayne.
One more thing, I think I may be incompetent in getting myself understood.
Here is My problem:
I downloaded the source code for the OpenGL Red Book. The source code comes
with more than sixty .c source files. I want to compile them.
That is I want to get 60 respective excutables. It is a bit tedius to compile
by creating a project. So I want to use the makefiles which come with it. I
have problems in running the makefiles. Error message pop up(stated above).
Maybe the two makefiles were not for MinGW, I will now stick to the IDE ,Yeah
,just to make life easier and avoid undesired frustration.
If you wish, I pasted the three(Oh? ) makefiles on the web
http://paste.dprogramming.com/dpw5f365
They are Imakefile Makefile Makefile.win
Looking at you makefile.win again, it si sobvious that this is not intended to
work with GCC, for starters it applies a command line option -nologo, which is
not a GCC command option.
And you have still not addresses my point about opengl32.lib is not a GNU
library. Continuing with this is pointless without sorrting out the correct
toolchain.
Why are you attempting to use Dev-C++ at all for this task?
Why have you not provided a linke to the source project you are attempting to
build? What tools do they suggest the project is intended for? You assume a
lot in thinking that I have any idea what "OpenGL Red Book" is. Of
course I have Googled it and am perhaps a little more clued up.
I have looked at the makefiles you posted elsewhere, and line 6 of
makefile.win (the line make.exe was reporting as an error) is:
!include <ntwin32.mak>
That was 'lost' in your original post of the text because you failed to use
code mark-up as I suggested. Seeing that makes the problem rather obvious;
this is not a GNU makefile, but rather a a Microsoft Nmake makefile. This as
well as the fact that linking opengl32.lib is doomed to failure using MinGW
suggests that you should do as I suggested earlier and use the Microsoft VC++
toolchain to build this code. It comes with the nmake.exe utility so you can
build it form teh command line, or use it in a "Makefile Project"
within the IDE.
https://sourceforge.net/projects/dev-
cpp/forums/forum/48211/topic/1035458
OK Thanks,friends。