1

I want to link an existing shared library (FlashRuntimeExtensions.so) to my C-code while compiling my own shared library. But whatever I try I always get the same error; that the file is in a wrong format. Does anybody have an idea on how to solve this?

Here is my compile command:

$ g++ -Wall ane.c FlashRuntimeExtensions.so -o aneObject FlashRuntimeExtensions.so: could not read symbols: File in wrong format collect2: ld gaf exit-status 1 terug 
7
  • 1
    $ file FlashRuntimeExtensions.so what's the output of this command ? Commented Dec 13, 2012 at 9:04
  • stackoverflow.com/questions/2527780/… Commented Dec 13, 2012 at 9:10
  • @SirDarius: FlashRuntimeExtensions.so: ELF 32-bit LSB shared object, ARM, version 1 (SYSV), dynamically linked, stripped Commented Dec 13, 2012 at 9:14
  • Are you (cross)compiling for ARM? Commented Dec 13, 2012 at 9:17
  • @tsurko Yes but I am not sure about the cross-compiling. I just want to compile a shared library that can be used on Android devices. Commented Dec 13, 2012 at 9:20

3 Answers 3

1

Your command line tries to generate x86 code and link it to ARM code using the native g++ available in your distribution.

This will not work. Use the Android NDK available here: http://developer.android.com/tools/sdk/ndk/index.html

The NDK includes a set of cross-toolchains (compilers, linkers, etc..) that can generate native ARM binaries on Linux, OS X, and Windows (with Cygwin) platforms.

Sign up to request clarification or add additional context in comments.

Comments

0

In general .so will be linked using -l.

for example, pthread -lpthread we use.

gcc sample.c -o myoutput -lpthread

But as per @chill's statement, what you are doing in command is correct only.

I suggest you to refer the following link.

C++ Linker Error SDL Image - could not read symbols

3 Comments

The OP command line by itself is perfectly OK. There's no such requirement to link libraries (shared or not) only using -l option.
Hmm when I try that it gives me the error that it can not find the specified library, even if I specify the path with the -L option.. But it could be a compatibility problem reading from the link.
When I try to compile it as a 32 bit library with the -m32 option the result is not different from the previous result
0

It should be an architecture mismatch. I faced this problem once, I have solved it by building the libs in same target platform and it is obvious. If you are using linux or Unix like OS you can see that by file command and if you are using windows you can see that using Dependency Walker. You need to make sure that all the libs matches architecture.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.