Page 1 of 1
compiling C++ class problem
Posted: Mon May 27, 2002 11:00 pm
by krillzip
Hi! I have problems compiling a C++ file containing
a test class to a binary
C++ sourcecode:
class TestClass
{
public:
TestClass(){};
~TestClass(){};
};
int main()
{
TestClass Test;
while(true){}
return false;
}
Makefile:
kernel : kernel.o
ld -nostdlib -nostdinc -fno-builtin -fno-exceptions -o kernel.bin -e main -oformat binary -Ttext 0x00100000 kernel.o
kernel.o : kernel.cpp
gcc -ffreestanding -nostdlib -nostdinc -fno-builtin -fno-rtti -fno-exceptions kernel.cpp -r
Error:
gcc -ffreestanding -nostdlib -nostdinc -fno-builtin -fno-rtti -fno-exceptions kernel.cpp -r
In file included from kernel.cpp:1:
c:/djgpp/lib/gcc-lib/djgpp/3.04/djgpp.ver:1:25: No include path in which to find sys/version.h
make.exe: *** [kernel.o] Error 1
do you think you can help me guys???
RE:compiling C++ class problem
Posted: Mon May 27, 2002 11:00 pm
by J. Weeks
>Makefile:
>kernel : kernel.o
> ld -nostdlib -nostdinc -fno-builtin -fno-exceptions -o kernel.bin -e main -oformat binary -Ttext 0x00100000 kernel.o
>
>kernel.o : kernel.cpp
> gcc -ffreestanding -nostdlib -nostdinc -fno-builtin -fno-rtti -fno-exceptions kernel.cpp -r
>
>Error:
>
>gcc -ffreestanding -nostdlib -nostdinc -fno-builtin -fno-rtti -fno-exceptions kernel.cpp -r
>In file included from kernel.cpp:1:
>c:/djgpp/lib/gcc-lib/djgpp/3.04/djgpp.ver:1:25: No include path in which to find sys/version.h
>make.exe: *** [kernel.o] Error 1
>
>do you think you can help me guys???
Well, it seems to me that, since you didn't include
sys/version.h yourself, it must be a standard include,
in which case, removing the -nostdinc might fix
it (granted, it might cause other problems as well...
that's why I use C/Asm for OS-Dev
Jeff
RE:compiling C++ class problem
Posted: Mon May 27, 2002 11:00 pm
by Guest
>On 2002-05-28 13:06:51, krillzip wrote:
>gcc -ffreestanding -nostdlib -nostdinc -fno-builtin -fno-rtti -fno-exceptions kernel.cpp -r
>In file included from kernel.cpp:1:
>c:/djgpp/lib/gcc-lib/djgpp/3.04/djgpp.ver:1:25: No include path in which to find sys/version.h
>make.exe: *** [kernel.o] Error 1
>
>do you think you can help me guys???
DJGPP wants to include <sys/version.h> in every source file. If you use -nostdinc then
it won't find it. You have two options: either,
a) add -I/path/to/standard/includes to the command line
b) make your own sys/version.h and add its directory using -I/path/to/custom/includes
RE:compiling C++ class problem
Posted: Mon May 27, 2002 11:00 pm
by Guest
>On 2002-05-28 19:46:11, Anonymous wrote:
>>On 2002-05-28 13:06:51, krillzip wrote:
>>gcc -ffreestanding -nostdlib -nostdinc -fno-builtin -fno-rtti -fno-exceptions kernel.cpp -r
I would use -c instead of -r
>>In file included from kernel.cpp:1:
>>c:/djgpp/lib/gcc-lib/djgpp/3.04/djgpp.ver:1:25: No include path in which to find sys/version.h
To me, this looks like a bug in DJGPP.
I compiled with GCC 2.95.2 and got a different error from the linker:
kernel.o(.text+0x6c):kernel.cpp: undefined reference to `___builtin_delete'
make.exe: *** [kernel] Error 1
>it won't find it. You have two options: either,
>
>a) add -I/path/to/standard/includes to the command line
>b) make your own sys/version.h and add its directory using -I/path/to/custom/includes
c) downgrade to GCC 2.95.2
RE:compiling C++ class problem
Posted: Tue May 28, 2002 11:00 pm
by krillzip
>On 2002-05-28 13:25:17, J. Weeks wrote:
>>Makefile:
>>kernel : kernel.o
>> ld -nostdlib -nostdinc -fno-builtin -fno-exceptions -o kernel.bin -e main -oformat binary -Ttext 0x00100000 kernel.o
>>
>>kernel.o : kernel.cpp
>> gcc -ffreestanding -nostdlib -nostdinc -fno-builtin -fno-rtti -fno-exceptions kernel.cpp -r
>>
>>Error:
>>
>>gcc -ffreestanding -nostdlib -nostdinc -fno-builtin -fno-rtti -fno-exceptions kernel.cpp -r
>>In file included from kernel.cpp:1:
>>c:/djgpp/lib/gcc-lib/djgpp/3.04/djgpp.ver:1:25: No include path in which to find sys/version.h
>>make.exe: *** [kernel.o] Error 1
>>
>>do you think you can help me guys???
>
>Well, it seems to me that, since you didn't include
>sys/version.h yourself, it must be a standard include,
>in which case, removing the -nostdinc might fix
>it (granted, it might cause other problems as well...
>that's why I use C/Asm for OS-Dev
>
>Jeff
How do I know which files is standard includes??
have any idea???
RE:compiling C++ class problem
Posted: Tue May 28, 2002 11:00 pm
by krillzip
>On 2002-05-28 19:46:11, Anonymous wrote:
>>On 2002-05-28 13:06:51, krillzip wrote:
>>gcc -ffreestanding -nostdlib -nostdinc -fno-builtin -fno-rtti -fno-exceptions kernel.cpp -r
>>In file included from kernel.cpp:1:
>>c:/djgpp/lib/gcc-lib/djgpp/3.04/djgpp.ver:1:25: No include path in which to find sys/version.h
>>make.exe: *** [kernel.o] Error 1
>>
>>do you think you can help me guys???
>
>DJGPP wants to include <sys/version.h> in every source file. If you use -nostdinc then
>it won't find it. You have two options: either,
>
>a) add -I/path/to/standard/includes to the command line
>b) make your own sys/version.h and add its directory using -I/path/to/custom/includes
I changed the Makefile to this:
kernel.bin : kernel.o
ld -nostdlib -fno-builtin -fno-exceptions -o kernel.bin -e main -oformat binary -Ttext 0x00100000 kernel.o
kernel.o : kernel.cpp
gcc -ffreestanding -nostdlib -fno-builtin -fno-rtti -fno-exceptions kernel.cpp -c
And got this error:
E:\demo>make
gcc -ffreestanding -nostdlib -fno-builtin -fno-rtti -fno-exceptions kernel.cpp -c
ld -nostdlib -fno-builtin -fno-exceptions -o kernel.bin -e main -oformat binary -Ttext 0x00100000 kernel.o
C:\DJGPP\BIN/ld.exe: cannot open binary: No such file or directory (ENOENT)
make.exe: *** [kernel] Error 1
RE:compiling C++ class problem
Posted: Tue May 28, 2002 11:00 pm
by J. Weeks
>How do I know which files is standard includes??
>have any idea???
Short of looking through all the docs, I'm not
sure, unfortunately. Under Linux, there's an
include directory:
/usr/lib/gcc-lib/$SYS-$LINUX-$VENDOR/$VERSION/include
That might contain some or all of them, but
off-hand, I really don't know.
Interestingly enough, I don't even have a
sys/version.h file.
You might want to email DJ Delorie...?
Jeff
RE:compiling C++ class problem
Posted: Tue May 28, 2002 11:00 pm
by Guest
>On 2002-05-29 12:21:37, krillzip wrote:
>And got this error:
>
>E:\demo>make
>gcc -ffreestanding -nostdlib -fno-builtin -fno-rtti -fno-exceptions kernel.cpp -c
>ld -nostdlib -fno-builtin -fno-exceptions -o kernel.bin -e main -oformat binary -Ttext 0x00100000 kernel.o
>C:\DJGPP\BIN/ld.exe: cannot open binary: No such file or directory (ENOENT)
>make.exe: *** [kernel] Error 1
You missed an equals sign between -oformat and binary. You need to write -oformat=binary instead.
RE:compiling C++ class problem
Posted: Wed May 29, 2002 11:00 pm
by krillzip
I took a look at it and the sys/version.h file was not
at the location spicified by the path instead it was in the standard
include directory C:\djgpp\include\sys\version. It included only some
mdefines
RE:compiling C++ class problem
Posted: Wed May 29, 2002 11:00 pm
by krillzip
I used -oformat=binary, and got a very strange output, it was in the format coff-go32-exe. instead I tried to use strip command and succeeded to convert to
binary it worked.