Date: Mon, 27 Aug 2001 14:57:27 -0700 (PDT) From: Will Robinson To: Subject: Re: linux->dos cross-compiler In-Reply-To: <3B87B4F3.22540.33D4FC@localhost> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Reply-To: djgpp AT delorie DOT com Errors-To: nobody AT delorie DOT com X-Mailing-List: djgpp AT delorie DOT com X-Unsubscribes-To: listserv AT delorie DOT com Precedence: bulk > > string.cpp: In function `int main()': > > string.cpp:5: `string' undeclared (first use this function) > > string.cpp:5: (Each undeclared identifier is reported only once for each > > function it appears in.) > > string.cpp:5: parse error before `=' token > > string class is now namespace std. Doh! Please pardon my ignorance...adding using std::string and such throughout the code has allowed me to compile all the source files! Now for (hopefully the last) hurdle...linking. I've had to do some (I think) odd things to get my code to even come close to linking: -Explicitly included crt0.o in the list of object files to link. -Put -lc -lstdc++ -lgcc at the end of the linker command line. And I still get errors like these: /opt/djgpp/i586-pc-msdosdjgpp/lib/libgcc.a(unwind-dw2-fde.o): In function `read_encoded_value_with_base': unwind-dw2-fde.c:211: multiple definition of `__register_frame_info' /opt/djgpp/i586-pc-msdosdjgpp/lib/libc.a(rfinfo.o)(.text+0x0):rfinfo.c: first defined here /opt/djgpp/i586-pc-msdosdjgpp/lib/libgcc.a(unwind-dw2.o): In function `read_encoded_value_with_base': unwind-dw2.c:211: undefined reference to `strlen' /opt/djgpp/i586-pc-msdosdjgpp/lib/libgcc.a(unwind-dw2-fde.o): In function `base_from_object': unwind-dw2-fde.c:231: undefined reference to `strlen' /opt/djgpp/i586-pc-msdosdjgpp/lib/libstdc++.a(locale.o): In function `std::locale::global(std::locale const&)': locale.cc:717: undefined reference to `setlocale' /opt/djgpp/i586-pc-msdosdjgpp/lib/libstdc++.a(locale.o): In function `std::ctype::do_toupper(char*, char const*) const': locale.cc:55: undefined reference to `toupper' /opt/djgpp/i586-pc-msdosdjgpp/lib/libstdc++.a(locale.o): In function `std::ctype::do_tolower(char*, char const*) const': locale.cc:70: undefined reference to `tolower' So it looks like __register_frame_info is defined both in libc.a and libgcc.a, and that ld-dos isn't seeing the definitions of strlen, setlocale, toupper, and tolower. I don't know what to do about the first problem , but the second is especially puzzling, since running nm-dos libc.a --print-file-name | grep strlen gives: libc.a:strlen.o:00000024 b .bss libc.a:strlen.o:00000024 d .data libc.a:strlen.o:00000000 t .text libc.a:strlen.o:00000000 t ___gnu_compiled_c libc.a:strlen.o:00000000 T _strlen libc.a:strlen.o:00000000 t gcc2_compiled. libc.a:c1args.o:0000004c t _far_strlen And I get similar results for toupper, tolower, and setlocale. When I add a --verbose switch to my ld-dos command line, I find that it is indeed using the right libc.a library, and is accessing a lot of files from it... attempt to open /opt/djgpp/i586-pc-msdosdjgpp/lib/libc.a succeeded (/opt/djgpp/i586-pc-msdosdjgpp/lib/libc.a)printf.o (/opt/djgpp/i586-pc-msdosdjgpp/lib/libc.a)npxsetup.o (/opt/djgpp/i586-pc-msdosdjgpp/lib/libc.a)fflush.o . . . ...but that strlen.o, toupper.o, tolower.o, and setlocal.o are not in the list of files loaded. It's possible that other files are missing also, but these 4 symbols are the only things turning up as unresolved in what I'm currently trying to compile. Any idea why they would show up in nm but not be included during linking? One thing's for sure...if I ever get this working correctly I'm going to write up a nice long account of how it was done! Thanks, Will Robinson