1

I am updating some old C++ projects to build on a 64-bit Linux machine for the first time, and I don't have much Linux experience. I need to build everything as 32-bit binaries, so I'm building everything with -m32 in the compiler and linker flags. I'm finding that, when linking to their dependencies, some must link with i386 shared objects, and some must link with x86_64 shared objects. If I only include the wrong folder in the linking path (-L/path/to/wrong/folder), it says

/usr/bin/ld: skipping incompatible xxx.so when searching for -lxxx

which I've come to understand means the architecture doesn't match what I'm trying to build.

The makefiles are nearly identical for two such differing projects, so it doesn't seem like I'm doing something obviously wrong there, and -m32 appears in the calls to gcc and g++ in the terminal. What could be causing this difference? Should I be concerned, or is it typical for this to happen?

Let me know if more information is needed to answer; I'm not really sure, due to inexperience with Linux and gcc, so apologies in advance.

Community
  • 1
  • 1
Keith M
  • 853
  • 10
  • 28
  • 2
    If you're building a 32-bit executable, you have to link to 32-bit libraries. If you're getting errors linking to 32-bit libraries, something's gone wrong along the way and you need to give us some more details. –  Apr 22 '17 at 01:35
  • 1
    Run `file` on your `.o` files and it'll tell you whether they're 32-bit or 64-bit. (If you're building with `-m32`, they *should* be 32-bit.) – Wyzard Apr 22 '17 at 03:38

1 Answers1

0

Thanks @Wyzard and @duskwuff for the tips. I was indeed able to find my problem by using file on my .o files. It was just a silly mistake; I had inadvertently reverted the changes I made to one of the projects' make files, which included adding the -m32 flag. I think I misunderstood what the "x86_64" libraries are for, and that confused me (I had assumed it meant "32-bit process for 64-bit machine").

Keith M
  • 853
  • 10
  • 28
  • (I originally posted this in the question comments on Apr 24 '17 and voted to close my own question, but then someone upvoted it long after it was posted, so I guess the question, and the manner in which it was resolved, helped them anyway... Therefore, I'll add this community wiki answer instead.) – Keith M Jan 30 '19 at 17:35