There are many compilers in the list, including GCC; but G++ I cannot see; and I know I have it installed...
EDIT: Also, could someone recommend a link where I can read how to make a makefile? I tried to make
one from an example I found in Stack Overflow, but now the compiler says there are no instructions for
how to build a Debug target. I want life to be easy...
EDIT2: A set of official makefile examples would be nice; in fact, why can't the setup write a basic makefile that one can then modify as needed? The example I found in Stack Overflow has gazillions of arguments I have no idea what they are for, namely, this is what it is with my renaming of files from the example:
DL3D: DL3D.o math/numrepr.o
g++ -g -o DL3D DL3D.o math/numrepr.o -L/sw/lib/root -lCore -lCint -lRIO -lNet -lHist -lGraf -lGraf3d -lGpad -lTree -lRint \
-lPostscript -lMatrix -lPhysics -lMathCore -lThread -lz -L/sw/lib -lfreetype -lz -Wl,-framework,CoreServices \
-Wl,-framework,ApplicationServices -pthread -Wl,-rpath,/sw/lib/root -lm -ldl
DL3D.o: DL3D.cpp math/numrepr.h
g++ -g -c -pthread -I/sw/include/root DL3D.cc
math/numrepr.o: math/numrepr.h math/numrepr.cpp
g++ -g -c -pthread -I/sw/include/root math/numrepr.cpp
but I have no idea what those libraries, if they are libraries, are, or weather I need them.
I understand that Code Blocks is just an environment; but it would be a nice little extra...
Or, could someone recommend a GUI tool I could use to generate a makefile?
UPDATE: Found cbp2make and used it to get an initial makefile.
I'm now in the process of learning to understand the format and customizing it.
The main problem is my project was not properly set up; I had a math cpp file that my main.cpp needed, but
creating the file in CB doesn't add it to the project necessarily; so cbp2make read the project file and re-created
the problem I had.
Another bug in cbp2make is it names the targets in lowercase; CB expects them capitalized. Another problem
is it assumes the main file is named "main.cpp", which for me wasn't true; I had renamed it to DL3D.cpp.
So, but I managed to add the math file to the make.
This is what my makefile looks like so far:
#------------------------------------------------------------------------------#
# This makefile was generated by 'cbp2make' tool rev.147 #
#------------------------------------------------------------------------------#
WORKDIR = `pwd`
CC = g++
CXX = g++
AR = ar
LD = g++
WINDRES = windres
INC =
CFLAGS = -Wall
RESINC =
LIBDIR =
LIB = -lGL -lX11
LDFLAGS = -L/sw/lib/root
INC_DEBUG = $(INC)
CFLAGS_DEBUG = $(CFLAGS) -g
RESINC_DEBUG = $(RESINC)
RCFLAGS_DEBUG = $(RCFLAGS)
LIBDIR_DEBUG = $(LIBDIR)
LIB_DEBUG = $(LIB)
LDFLAGS_DEBUG = $(LDFLAGS)
OBJDIR_DEBUG = obj/Debug
DEP_DEBUG =
OUT_DEBUG = bin/Debug/DL3D
INC_RELEASE = $(INC)
CFLAGS_RELEASE = $(CFLAGS) -O2
RESINC_RELEASE = $(RESINC)
RCFLAGS_RELEASE = $(RCFLAGS)
LIBDIR_RELEASE = $(LIBDIR)
LIB_RELEASE = $(LIB)
LDFLAGS_RELEASE = $(LDFLAGS) -s
OBJDIR_RELEASE = obj/Release
DEP_RELEASE =
OUT_RELEASE = bin/Release/DL3D
OBJ_DEBUG = $(OBJDIR_DEBUG)/DL3D.o $(OBJDIR_DEBUG)/num_repr.o
OBJ_RELEASE = $(OBJDIR_RELEASE)/DL3D.o $(OBJDIR_RELEASE)/num_repr.o
all: debug release
clean: clean_debug clean_release
before_debug:
test -d bin/Debug || mkdir -p bin/Debug
test -d $(OBJDIR_DEBUG) || mkdir -p $(OBJDIR_DEBUG)
after_debug:
Debug: before_debug out_debug after_debug
out_debug: before_debug $(OBJ_DEBUG) $(DEP_DEBUG)
$(LD) $(LIBDIR_DEBUG) -o $(OUT_DEBUG) $(OBJ_DEBUG) $(LDFLAGS_DEBUG) $(LIB_DEBUG)
$(OBJDIR_DEBUG)/DL3D.o: DL3D.cpp
$(CC) $(CFLAGS_DEBUG) $(INC_DEBUG) -c DL3D.cpp -o $(OBJDIR_DEBUG)/DL3D.o
$(OBJDIR_DEBUG)/num_repr.o: math/num_repr.cpp
$(CC) $(CFLAGS_DEBUG) $(INC_DEBUG) -c math/num_repr.cpp -o $(OBJDIR_DEBUG)/num_repr.o
clean_debug:
rm -f $(OBJ_DEBUG) $(OUT_DEBUG)
rm -rf bin/Debug
rm -rf $(OBJDIR_DEBUG)
before_release:
test -d bin/Release || mkdir -p bin/Release
test -d $(OBJDIR_RELEASE) || mkdir -p $(OBJDIR_RELEASE)
after_release:
Release: before_release out_release after_release
out_release: before_release $(OBJ_RELEASE) $(DEP_RELEASE)
$(LD) $(LIBDIR_RELEASE) -o $(OUT_RELEASE) $(OBJ_RELEASE) $(LDFLAGS_RELEASE) $(LIB_RELEASE)
$(OBJDIR_RELEASE)/DL3D.o: DL3D.cpp
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c DL3D.cpp -o $(OBJDIR_RELEASE)/DL3D.o
$(OBJDIR_RELEASE)/num_repr.o: math/num_repr.cpp
$(CC) $(CFLAGS_RELEASE) $(INC_RELEASE) -c math/num_repr.cpp -o $(OBJDIR_RELEASE)/num_repr.o
clean_release:
rm -f $(OBJ_RELEASE) $(OUT_RELEASE)
rm -rf bin/Release
rm -rf $(OBJDIR_RELEASE)
.PHONY: before_debug after_debug clean_debug before_release after_release clean_release
It works as far as compiling the two files; but the linker tells me that all the functions from the math file
are undefined... :(
By the way, my first question still stands; why is there not G++ in the list of compilers to choose from?
I even changed the first definition in the make file from "CC = gcc" to "CC = g++", to try and force it to
use G++, but the compiler output still announces itself as GCC... ::)
Yeah, I wouldn't know how to build from the command line; I used to do my programming in Windows, using gui's; I'm new to linux and the command line world.
The build log:
-------------- Build: Debug in DL3D (compiler: GNU GCC Compiler)---------------
Skipping file (no compiler program set): math/num_repr.cpp
gcc -o bin/Debug/DL3D
gcc: fatal error: no input files
compilation terminated.
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
This is how my two files appear in the cbp file:
<Unit filename="DL3D.cpp">
<Option compilerVar="CXX" />
</Unit>
<Unit filename="math/num_repr.cpp">
<Option compilerVar="CXX" />
</Unit>
Is that correct?
Actually, I replaced "CXX" with "g++" but doesn't seem to help much...
-------------- Clean: Debug in DL3D (compiler: GNU GCC Compiler)---------------
Cleaned "DL3D - Debug"
-------------- Build: Debug in DL3D (compiler: GNU GCC Compiler)---------------
Skipping file (no compiler program set): DL3D.cpp
Skipping file (no compiler program set): math/num_repr.cpp
gcc -o bin/Debug/DL3D
gcc: fatal error: no input files
compilation terminated.
Process terminated with status 1 (0 minute(s), 0 second(s))
1 error(s), 0 warning(s) (0 minute(s), 0 second(s))
Editing the CBP file is not a recommended practice, of course being XML does not help to prevent this.
You don't need the <Option compiler... stuff, just
<Unit filename="DL3D.cpp" />
<Unit filename="math/num_repr.cpp" />
I would delete the project, recreate it using thw wizard, add the two files and forget about it being a text file.
Never mind; I deleted the files created, ran the wizard again, thinking it might have a hidden button to select language; there was no such thing...
So I removed file main.c from the project, and added DL3D.cpp, as well as the other file, num_repr.cpp, and it compiles.
What I get now is,
/usr/bin/ld: obj/Debug/DL3D.o: in function `main':
/home/dd/DL3D/DL3D.cpp:243: undefined reference to `num_repr<unsigned char>::init(int, int, int, int, int, int, int, int)'
/usr/bin/ld: /home/dd/DL3D/DL3D.cpp:245: undefined reference to `num_repr<unsigned char>::num_totalbits()'
/usr/bin/ld: /home/dd/DL3D/DL3D.cpp:241: undefined reference to `num_repr<unsigned char>::~num_repr()'
/usr/bin/ld: /home/dd/DL3D/DL3D.cpp:241: undefined reference to `num_repr<unsigned char>::~num_repr()'
collect2: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 2 second(s))
5 error(s), 5 warning(s) (0 minute(s), 2 second(s))
... all of which functions ARE well defined in num_repr.cpp and declared in the included header num_repr.h; so I think there's still a problem with linker setup.
Maybe it thinks it is linking C instead of C++?
EDIT: Both files are actually compiled; I see DL3D.o and num_repr.o in the obj folder; but somehow it says 'undefined'...
Do you have write the template core functions ?
typename<T>
num_totalbits<T>::num_totalbits()
{
}