I realize that nobody seems to use Open Watcom's C/C++ compiler but it's the only precompiled C compiler for Windows which compiles code to Linux (I tried building GCC in every way imaginable without success). I've successfully built a few hello world programs without much trouble. However, with a bigger (10,000 line project), I end up with a ton of linking errors.

I am using Code::Blocks 8.02 with Open Watcom 1.8:

Linking dynamic library: ..\bin\libci.so
Error! E2028: __CHK is an undefined reference
Error! E2028: strcmp_ is an undefined reference
Error! E2028: strlen_ is an undefined reference
Error! E2028: strstr_ is an undefined reference
Error! E2028: strchr_ is an undefined reference
Error! E2028: memcpy_ is an undefined reference
Error! E2028: fread_ is an undefined reference
Error! E2028: __get_errno_ptr_ is an undefined reference
Error! E2028: strerror_ is an undefined reference
Error! E2028: ___iob is an undefined reference
Error! E2028: fopen_ is an undefined reference
Error! E2028: fgetc_ is an undefined reference
Error! E2028: freopen_ is an undefined reference
Error! E2028: ungetc_ is an undefined reference
Error! E2028: fclose_ is an undefined reference
Error! E2028: realloc_ is an undefined reference
Error! E2028: free_ is an undefined reference
Error! E2028: fprintf_ is an undefined reference
Error! E2028: _fltused_ is an undefined reference
Error! E2028: __8087 is an undefined reference
Error! E2028: rand_ is an undefined reference
Error! E2028: srand_ is an undefined reference
Error! E2028: __HugeValue is an undefined reference
Error! E2028: abs_ is an undefined reference
Error! E2028: fputs_ is an undefined reference
Error! E2028: fgets_ is an undefined reference
Error! E2028: longjmp_ is an undefined reference
Error! E2028: exit_ is an undefined reference
Error! E2028: _setjmp_ is an undefined reference
Error! E2028: tmpfile_ is an undefined reference
Error! E2028: fscanf_ is an undefined reference
Error! E2028: fwrite_ is an undefined reference
Error! E2028: fseek_ is an undefined reference
Error! E2028: ftell_ is an undefined reference
Error! E2028: setvbuf_ is an undefined reference
Error! E2028: fflush_ is an undefined reference
Error! E2028: __IsTable is an undefined reference
Error! E2028: localeconv_ is an undefined reference
Error! E2028: tolower_ is an undefined reference
Error! E2028: strrchr_ is an undefined reference
Error! E2028: getenv_ is an undefined reference
Error! E2028: strtoul_ is an undefined reference
Error! E2028: sprintf_ is an undefined reference
Error! E2028: strncpy_ is an undefined reference
Error! E2028: strcpy_ is an undefined reference
Error! E2028: strcat_ is an undefined reference
Error! E2028: strcspn_ is an undefined reference
Error! E2028: strncat_ is an undefined reference
Error! E2028: system_ is an undefined reference
Error! E2028: remove_ is an undefined reference
Error! E2028: rename_ is an undefined reference
Error! E2028: tmpnam_ is an undefined reference
Error! E2028: clock_ is an undefined reference
Error! E2028: time_ is an undefined reference
Error! E2028: gmtime_ is an undefined reference
Error! E2028: localtime_ is an undefined reference
Error! E2028: strftime_ is an undefined reference
Error! E2028: mktime_ is an undefined reference
Error! E2028: setlocale_ is an undefined reference
Error! E2028: memcmp_ is an undefined reference
Error! E2028: toupper_ is an undefined reference
Error! E2028: memchr_ is an undefined reference
Error! E2028: strpbrk_ is an undefined reference
Error! E2028: strcoll_ is an undefined reference
Error! E2028: fputc_ is an undefined reference
Error! E2028: printf_ is an undefined reference
Error! E2028: __chipbug is an undefined reference
Error! E2028: __fptan_chk is an undefined reference
Error! E2028: __fdiv_fpr is an undefined reference
Error! E2028: __fpatan_wrap is an undefined reference
Error! E2028: __fprem_chk is an undefined reference
Error! E2028: __set_ERANGE_ is an undefined reference
Error! E2028: __ZBuf2LD is an undefined reference
Error! E2028: memset_ is an undefined reference
Error! E2028: __get_std_stream_ is an undefined reference
Error! E2028: __set_EDOM_ is an undefined reference
Warning! W1023: no starting address found, using 00000000
Error! E2044: exported symbol __CHK not found
Error! E2044: exported symbol strcmp_ not found
Error! E2044: exported symbol strlen_ not found
Error! E2044: exported symbol strstr_ not found
Error! E2044: exported symbol strchr_ not found
Error! E2044: exported symbol memcpy_ not found
Error! E2044: exported symbol fread_ not found
Error! E2044: exported symbol __get_errno_ptr_ not found
Error! E2044: exported symbol strerror_ not found
Error! E2044: exported symbol ___iob not found
Error! E2044: exported symbol fopen_ not found
Error! E2044: exported symbol fgetc_ not found
Error! E2044: exported symbol freopen_ not found
Error! E2044: exported symbol ungetc_ not found
Error! E2044: exported symbol fclose_ not found
Error! E2044: exported symbol realloc_ not found
Error! E2044: exported symbol free_ not found
Error! E2044: exported symbol fprintf_ not found
Error! E2044: exported symbol _fltused_ not found
Error! E2044: exported symbol __8087 not found
Error! E2044: exported symbol rand_ not found
Error! E2044: exported symbol srand_ not found
Error! E2044: exported symbol __HugeValue not found
Error! E2044: exported symbol abs_ not found
Error! E2044: exported symbol fputs_ not found
Error! E2044: exported symbol fgets_ not found
Error! E2044: exported symbol longjmp_ not found
Error! E2044: exported symbol exit_ not found
Error! E2044: exported symbol _setjmp_ not found
Error! E2044: exported symbol tmpfile_ not found
Error! E2044: exported symbol fscanf_ not found
Error! E2044: exported symbol fwrite_ not found
Error! E2044: exported symbol fseek_ not found
Error! E2044: exported symbol ftell_ not found
Error! E2044: exported symbol setvbuf_ not found
Error! E2044: exported symbol fflush_ not found
Error! E2044: exported symbol __IsTable not found
Error! E2044: exported symbol localeconv_ not found
Error! E2044: exported symbol tolower_ not found
Error! E2044: exported symbol strrchr_ not found
Error! E2044: exported symbol getenv_ not found
Error! E2044: exported symbol strtoul_ not found
Error! E2044: exported symbol sprintf_ not found
Error! E2044: exported symbol strncpy_ not found
Error! E2044: exported symbol strcpy_ not found
Error! E2044: exported symbol strcat_ not found
Error! E2044: exported symbol strcspn_ not found
Error! E2044: exported symbol strncat_ not found
Error! E2044: exported symbol system_ not found
Error! E2044: exported symbol remove_ not found
Error! E2044: exported symbol rename_ not found
Error! E2044: exported symbol tmpnam_ not found
Error! E2044: exported symbol clock_ not found
Error! E2044: exported symbol time_ not found
Error! E2044: exported symbol gmtime_ not found
Error! E2044: exported symbol localtime_ not found
Error! E2044: exported symbol strftime_ not found
Error! E2044: exported symbol mktime_ not found
Error! E2044: exported symbol setlocale_ not found
Error! E2044: exported symbol memcmp_ not found
Error! E2044: exported symbol toupper_ not found
Error! E2044: exported symbol memchr_ not found
Error! E2044: exported symbol strpbrk_ not found
Error! E2044: exported symbol strcoll_ not found
Error! E2044: exported symbol fputc_ not found
Error! E2044: exported symbol printf_ not found
Error! E2044: exported symbol __chipbug not found
Error! E2044: exported symbol __fptan_chk not found
Error! E2044: exported symbol __fdiv_fpr not found
Error! E2044: exported symbol __fpatan_wrap not found
Error! E2044: exported symbol __fprem_chk not found
Error! E2044: exported symbol __set_ERANGE_ not found
Error! E2044: exported symbol __ZBuf2LD not found
Error! E2044: exported symbol memset_ not found
Error! E2044: exported symbol __get_std_stream_ not found
Error! E2044: exported symbol __set_EDOM_ not found

I currently have one of two explanations on this: either Open Watcom does not support creating .so libraries or I'm not linking a library that I should. Everything in its set of libraries is new to me besides what's in the Windows library set. Note that this builds without incident in GCC 4.4.0 for Windows.

What exactly are you trying to achieve here?

> it's the only precompiled C compiler for Windows which compiles code to Linux
> (I tried building GCC in every way imaginable without success). I've successfully built a few hello world
> programs without much trouble. However, with a bigger (10,000 line project), I end up with a ton of linking errors.

It looks like you're trying to generate your Linux code directly on your windows machine. Whilst this is entirely possible, it is also almost entirely dumb as well. Linux is perfectly capable of hosting a compiler.

The normal way of doing things is just to copy the source code between the platforms.
On the windows machine, you use a windows compiler to compile a windows executable.
On the Linux machine, you use the GCC compiler to compile a Linux executable.

I suspect the vast majority of linker errors you're seeing are down to you trying to use the host runtime libraries with the target object file. This WILL NOT WORK.

I would do that if I had the ability to Linux on this computer. However, I technically am not the owner of the computer I use and therefore am not able to install Linux on it. Open Watcom has a set of libraries for Linux, Windows, OS/2 and a few others I can't remember. It will use the proper set (as far as I know) for the platform. Also, just for reference, I did not compile Open Watcom.

Are you allowed to install virtual machines on it?

I am a limited user on this computer with no access to BIOS or any administrative controls.

Tell whoever is in charge that your setup is basically inadequate for someone writing large programs which need to be portable.

Fine for students doing homework on a single machine.
But being a "limited user" and trying serious cross-platform software development - forget it.
The next noose around your neck will be a similar inadequacy of lack of being able to run the debugger.

Either way, this problem does not appear to be because I'm cross-platform compiling. I tried building for Windows alone and it did not work. I know of many people who use MinGW for Linux to build Windows programs.

If no one here can tell me what I'm doing wrong, is there a board with an "Open Watcom" forum? I've been in to the IRC channel but it's virtually abandoned with 2-4 users online at one time. For such a big project, I would think there would at least be a community for support which I haven't found.

Member Avatar for iamthwee

Is this some kind of a joke? Are you telling me you don't have your own computer to install something like vmware, or god forbid, even QEMU?

And then download a linux iso, wack it onto your virtual machine with relative piece of mind it won't F*** up anything else? Then compile your the same code on the linux OS so you know for a FACT it's working as intended.

And this is a project of 10,000 lines? Go get yourself a cheap laptop/computer! Set up a virtual machine. Compile your code ON that virtual machine. Job done.

No this is not a joke. I programming for free and open source software, not commercially. In other words, even a $500 laptop would be beyond my range. Before this project and another 5,000 line project, my code wasn't even OS portable. I have someone else who does run Linux who tests if something works. I would have that person compile, however, he also has his things to do and compiling a project and testing it are 2 very different things.

All I'm looking for here is to figure out why my somewhat-above-hello-world program works but the actual project doesn't work.

As for fixing your code, all I can suggest is you compare a project which works, with one that doesn't in GREAT detail.
Your first post looked like it was missing libc entirely. Were you in the right place when you did ..\ in your relative path?

As for your circumstance, start asking round (politely) the local businesses to see if they have any spare equipment, Most usually have something sitting in a corner. Explain to them what it is you're trying to do. Who knows, make a few contacts and it might just come in handy job hunting time.

In a lot of places, it costs businesses money to throw stuff away, so giving it away is a cheap option. It might take you a couple of weeks to accumulate all you need, but it's only your time and effort.

I probably am missing libc and now I'm trying to figure out which file that is! I will take your advise and try doing a comparison of the linker options.

As for the local businesses, there really aren't that many around. It's probably 0.5 miles to the closest "store" around here and it's not really a store. Well, thanks for that tip though as I might try sometime.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.