LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (https://www.linuxquestions.org/questions/programming-9/)
-   -   cannot compile 32-bit applications on 64-bit ubuntu 9.04 (https://www.linuxquestions.org/questions/programming-9/cannot-compile-32-bit-applications-on-64-bit-ubuntu-9-04-a-731010/)

maxreason 06-05-2009 05:25 PM

cannot compile 32-bit applications on 64-bit ubuntu 9.04
 
I asked a similar question a few days ago on the ubuntu forum, but the responders have not been able to help me. I ask the question in this forum because it may be far more specific to software development than ubuntu. Sorry for this duplication.

We are developing a multiplatform 3D game/graphics/simulation application that adopts OpenGL for graphics but otherwise only calls functions in standard C function libraries. We've been developing on 32-bit ubuntu 8.04 until last week when we decided it was time to create a 64-bit version to take advantage of the extra CPU/SIMD registers and efficiencies available only in 64-bit mode. So we installed the 64-bit version of ubuntu 9.04 on our computers and tried to build the 32-bit debug version of our program in CodeBlocks (which is the development environment we've been working with). The only change we made to the project settings on the 32-bit debug/release versions was to add -m32 to force the tools to compile/assemble/link 32-bit mode code and libraries.

The current problem is, an attempt to build generates the following error (after apparently compiling all the source-code files without troubles):

ld cannot find -lstdc++

However, the following check indicates to me that these 32-bit libraries are installed in the correct directory.

Code:

cd /usr/lib32
ls -la libst*

lrwxrwxrwx 1 root root    18  2009-06-04 19:41 libstdc++.so.5 -> libstdc++.so.5.0.7
-rw-r--r-- 1 root root 737192  2008-05-09 23:18 libstdc++.so.5.0.7
lrwxrwxrwx 1 root root    19  2009-06-04 19:41 libstdc++.so.6 -> libstdc++.so.6.0.10
-rw-r--r-- 1 root root 950424  2009-03-16 18:03 libstdc++.so.6.0.10


I assume "stdc++" and "libstdc++" refer to the same package, right?

Our project settings don't explicitly include library stdc++ or libstdc++, but my source-code files do include some C standard libraries. I assume the build tools automatically include the stdc++ library. Correct?

I'm at a loss. This problem will probably appear obvious in retrospect --- once somebody explains what we're missing.

Matir 06-05-2009 07:22 PM

Is -L/usr/lib32 being passed to the linker? Even when linking with -m32, I believe you need to add the lib32 path.

maxreason 06-05-2009 08:25 PM

Quote:

Originally Posted by Matir (Post 3564743)
Is -L/usr/lib32 being passed to the linker? Even when linking with -m32, I believe you need to add the lib32 path.

I added -L/usr/lib32 to the linker options, but still get the same error. Any other ideas?

Matir 06-05-2009 08:39 PM

Are you even using c++, or just C? I'm not sure why it would need libstdc++. What functions are you using for that?

Try installing the g++-multilib package.

maxreason 06-06-2009 12:18 AM

Quote:

Originally Posted by Matir (Post 3564795)
Are you even using c++, or just C? I'm not sure why it would need libstdc++. What functions are you using for that?

Try installing the g++-multilib package.

Well, I prefer to program in C, but I prefer to have a few simple C++ features available (like // comments, late variable declarations, a few other trivialities). So essentially I program in C but compile with C++ to get those flexibilities. My programs have no classes, no templates, and definitely nothing fancy. I will try installing that package just on general principles unless you say "never mind" based upon the comments I just made above.

Someone in the OpenGL forum figured out my problem... pretty obvious in retrospect.

cd /usr/lib32
ln -s libstdc++.so.6 libstdc++.so

This creates a symbolic link named "libstdc++.so" that refers to "libstdc++.so.6" (the most recent version I have installed). That makes sense to me. Presumably the CodeBlocks IDE (and/or gcc compiler tools) automatically links to "libstdc++.so" with the assumption that will be linked to the most recent installed version of that library. Presumably most applications prefer to link to the newest library, unless they have some unusual need to link to an older version.

I'm guessing the programmer who made the package that contains libstdc++.so forgot to include the symbolic link. I notice this symbolic link is also missing from the /usr/lib64 directory! I guess I better add one into that directory too, before I forget!

Thanks for the ideas.

Matir 06-06-2009 08:58 PM

g++-multilib fixed the problem for me when I tried to build a test program based on what you said. I didn't need to create a symlink either. In any case, if the symlink is working for you, then you should be fine.

dmail 06-07-2009 06:41 AM

Quote:

Well, I prefer to program in C, but I prefer to have a few simple C++ features available (like // comments, late variable declarations,
What "other trivialities" do you use as these are both available in c99.

maxreason 06-07-2009 03:27 PM

unknown trivialities
 
Quote:

Originally Posted by dmail (Post 3565847)
What "other trivialities" do you use as these are both available in c99.

I was afraid someone would ask that. My answer is, I'm not sure. And I'm not sure whether gcc is c99, or what else changes. I do recall being "dinged" by the compiler, though I can't remember any more. I suppose I could figure out how to tell CodeBlocks to compile with C/C99 and watch it complain.

Wait, now I remember what might be the problem. My applications are cross-platform, meaning they compile on Linux and Windoze. As I recall, getting the same code to compile on both gcc/g++ and VisualStudio was lots easier as C++ code. But who knows what drove me to this... 'twas a long time ago in a galaxy far, far away.


All times are GMT -5. The time now is 01:59 PM.