LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 06-05-2009, 05:25 PM   #1
maxreason
Member
 
Registered: Dec 2007
Location: phobos, mars
Distribution: 64-bit ubuntu 12.04 LTS
Posts: 205

Rep: Reputation: 15
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.
 
Old 06-05-2009, 07:22 PM   #2
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 117Reputation: 117
Is -L/usr/lib32 being passed to the linker? Even when linking with -m32, I believe you need to add the lib32 path.
 
Old 06-05-2009, 08:25 PM   #3
maxreason
Member
 
Registered: Dec 2007
Location: phobos, mars
Distribution: 64-bit ubuntu 12.04 LTS
Posts: 205

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Matir View Post
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?
 
Old 06-05-2009, 08:39 PM   #4
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 117Reputation: 117
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.
 
Old 06-06-2009, 12:18 AM   #5
maxreason
Member
 
Registered: Dec 2007
Location: phobos, mars
Distribution: 64-bit ubuntu 12.04 LTS
Posts: 205

Original Poster
Rep: Reputation: 15
Quote:
Originally Posted by Matir View Post
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.

Last edited by maxreason; 06-06-2009 at 12:19 AM.
 
Old 06-06-2009, 08:58 PM   #6
Matir
Moderator
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,507

Rep: Reputation: 117Reputation: 117
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.
 
Old 06-07-2009, 06:41 AM   #7
dmail
Member
 
Registered: Oct 2005
Posts: 970

Rep: Reputation: Disabled
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.
 
Old 06-07-2009, 03:27 PM   #8
maxreason
Member
 
Registered: Dec 2007
Location: phobos, mars
Distribution: 64-bit ubuntu 12.04 LTS
Posts: 205

Original Poster
Rep: Reputation: 15
unknown trivialities

Quote:
Originally Posted by dmail View Post
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
64 bit cpu-64 bit Ubuntu-are there 32 bit app issues? sofasurfer Ubuntu 7 04-09-2014 02:02 PM
LXer: Running 32-bit Applications on 64-bit Debian GNU/Linux LXer Syndicated Linux News 2 01-06-2010 12:26 PM
Compile 32-bit kernel on a 64-bit machine kushalkoolwal Debian 6 06-15-2009 05:48 PM
cannot compile 32-bit application on 64-bit ubuntu 9.04 maxreason Ubuntu 5 06-06-2009 10:28 PM
LXer: Using Adobe Flash and other 32-bit applications on 64-bit Linux LXer Syndicated Linux News 0 07-24-2008 07:10 PM


All times are GMT -5. The time now is 06:00 AM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration