I guess you can tell it to put the multiboot header in its own section and then place it. I'm not sure you can tell it not to throw it away though, but then again you'll probably use it from your code so it won't remove it anyway.pcmattman wrote:Actually there's another reason why that loader has to go first - it holds the multiboot header...
Linking fails with templates? [SOLVED]
Re: Linking fails with templates?
I need to see the whole header file. What the errors till me is that it can't find the correct implementation. Just remember the template can never be compiled. only the resulting code from the template can be compiled (i.e each time a template is used with different args, a copy of that code is compiled with them arguments and added to the final executable. by arguments I mean the stuff between the < and >).pcmattman wrote:Any ideas?
Microsoft: "let everyone run after us. We'll just INNOV~1"
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
Here you go:
Note that when I told G++ to link as well as compile (ie. not doing the link myself) there were no errors. The only problem was it complained about the loader object format (assembled via NASM). And there is no way I'm converting it to GAS syntax.
Edit: OK, here's what happens with the following command line:
Outputs:
loader.obj is an ELF object file assembled with NASM. Any ideas?
Edit 2: Wait. The error comes from 'stubify.exe' - converting the final image to an exe??? I'm playing around with the command line. Once I've got it working, I'm making a makefile so I don't keep getting complaints about command line length...
Edit 3: Nope, still the same problems... I just can't get templates to work!
Code: Select all
#include <console.h>
template< class T >
class Accumulator
{
public:
Accumulator() { };
~Accumulator() { };
T Value();
T operator = ( T val );
private:
T m_val;
};
template< class T > T Accumulator<T>::Value()
{
return(m_val);
}
template< class T > T Accumulator<T>::operator = ( T val )
{
return( m_val = val );
}
Edit: OK, here's what happens with the following command line:
Code: Select all
gpp -I "include" -masm=intel loader.obj *.cc */*.cc -nostdlib -fno-builtin -fno-rtti -fno-exceptions -Wl,-T linker.ld
Code: Select all
Warning: input file is not COFF or stubbed COFF
Edit 2: Wait. The error comes from 'stubify.exe' - converting the final image to an exe??? I'm playing around with the command line. Once I've got it working, I'm making a makefile so I don't keep getting complaints about command line length...
Edit 3: Nope, still the same problems... I just can't get templates to work!
Code: Select all
c:/djgpp/bin/ld.exe: c:/djgpp/tmp/ccnnBa6D.o: Unrecognized storage class 127 for /4 symbol `Accumula
tor<int>::Accumulator()'
c:/djgpp/bin/ld.exe: c:/djgpp/tmp/ccnnBa6D.o: Unrecognized storage class 127 for /44 symbol `Accumul
ator<int>::test()'
c:/djgpp/bin/ld.exe: c:/djgpp/tmp/ccnnBa6D.o: Unrecognized storage class 127 for /87 symbol `Accumul
ator<int>::operator=(int)'
c:/djgpp/bin/ld.exe: c:/djgpp/tmp/ccnnBa6D.o: Unrecognized storage class 127 for /127 symbol `Accumu
lator<int>::Value()'
You might reconsider this because the problems now seem very familiar and i fixed it by converting the bootloader to GAS and because of the integration with the C++ part it works perfectly. My bootsector does not contain any data, only code, to load the stage1 loader. .. but that is not what you want to hear.And there is no way I'm converting it to GAS syntax
You can either use a cross-compiler and also build your C++ code as ELF or you have to convert the loader.obj to COFF format. I guess you can use objcopy for that.
Or you could build you loader.obj with 'nasm -f coff' to compile it in coff format.
Author of COBOS
-
- Member
- Posts: 2566
- Joined: Sun Jan 14, 2007 9:15 pm
- Libera.chat IRC: miselin
- Location: Sydney, Australia (I come from a land down under!)
- Contact:
OK, I must know nothing about templates... Visual C++ throws this error on some template code I wrote:
This is insanity! Can someone please save me and tell me how to do the templates properly?
Edit: OK, almost there! New problem:
From the following:
Any ideas?
Edit 2: Actually, it's not a new problem... This is somewhat frustrating.
Code: Select all
main.obj : error LNK2001: unresolved external symbol "public: int __thiscall CLinkedList<int>::test(int)" (?test@?$CLinkedList@H@@QAEHH@Z)
Edit: OK, almost there! New problem:
Code: Select all
c:/djgpp/bin/ld-elf.exe: C:\OSDev\MattiseOS\CPP_Kernel\kernel.o: Unrecognized storage class 127 for
/4 symbol `__ZN4TestIiE2hiEi'
Code: Select all
template< typename _T >
class Test
{
public:
void hi( _T );
};
template< typename _T > void Test<_T>::hi( _T t )
{
kprintf( "hi!" );
}
Edit 2: Actually, it's not a new problem... This is somewhat frustrating.