On 09/04/2016 01:45 AM, R n wrote:
Thanks, Charles.


I just want to build it anyway to make it work 😊


Been there, just once... ;-)

After writing this I kinda think this is all you need to do, MAYBE, 
re-configure ffmpeg and change the order

--extra-libs=-L/<path to>/mylibrary/ -lmylibrarytest -lstdc++

See explanation and more info below.


.../binutils/2.25/centos6-native/da39a3e/bin/ld: 
.../mylibrary/0.1/gcc-4.9-glibc-2.20/80414d5/lib/libmylibrary.a(mylibrary_file.o):
relocation R_X86_64_32 against `.bss' can not be used when making a shared 
object; recompile with -fPIC

.../mylibrary/0.1/gcc-4.9-glibc-2.20/80414d5/lib/libmylibrary.a: error adding 
symbols: Bad value

collect2: error: ld returned 1 exit status

make: *** [libavfilter/libavfilter.so.6] Error 1

At this point I realized what you are doing...had to go reread your first 
message.

Your build
"The wrapper consists of a C header file and some C functions which call the C++ 
functions (in the C++ files)"

I guess you mean something like this mylibrary_file.cpp

MylibraryClass myobj;
extern "C" void mylib_magic_c_foo()
{
   myobj.DoTheMagicFoo();
}

Build your lib with fPIC on each object (source file)->(.o)

g++ -fPIC -O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector [blah 
blah] ... -o mylibrary_file.o -c mylibrary_file.cpp

Then build your library as a shared lib

LDFLAGS += -fPIC -shared

g++ -fPIC -shared -O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector 
[blah blah]... mylibrary_file.o -o libmylibrary.so

When ffmpeg builds it need to do the -L.../<path to>/mylibrary/ -lmylibrary 
-lstdc++

The -L path then your mylibrary all before -lstdc++ (linker "express need then 
satisfy need")

--extra-libs=-L/<path to>/mylibrary/ -lmylibrarytest -lstdc++'

No idea if it will work, just a theory...sorry not an expert


The full building commands are too big and I just copied something (below) I 
feel important. Please let me know if I missed anything.
2. This is the compile command for building FFmpeg (which is calling my 
library):

CFLAGS='-O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector 
--param=ssp-buffer-size=4 -fno-omit-frame-pointer
-momit-leaf-frame-pointer -m64 -mtune=generic -nostdinc -grecord-gcc-switches 
... -fPIC'
[...]
Here, I did not see anything like "Wextra -DDEBUG..."

FYI : They don't have anything to do with your problem
-W is options passed to compiler -Wl is passed to linker and -D is defines 
passed to C Pre Processor
-Wextra is added to -Wall for compile warnings, I used it for 
-Wmissing-field-initializers and -Wunused-parameter
-DDEBUG is just enabling my code where I have #if defined(DEBUG)


3. This is the compile command for building my library:
CFLAGS='-O3 -g -pipe -Wall -Wp,-D_FORTIFY_SOURCE=2 -fstack-protector 
--param=ssp-buffer-size=4 -fno-omit-frame-pointer
-momit-leaf-frame-pointer -m64 -mtune=generic -nostdinc -grecord-gcc-switches 
...
[...]
                   '--extra-libs=-L /lib64 -lstdc++ -lmylibrarytest',

.../binutils/2.25/centos6-native/da39a3e/bin/ld: 
.../mylibrary/0.1/gcc-4.9-glibc-2.20-fb/8fd4fe1/lib/libmylibrary.a(my_file.cpp.o):
relocation R_X86_64_32 against `.bss' can not be used when making a shared 
object; recompile with -fPIC

-fPIC is for shared objects, you have to compile all the object code with -fPIC 
to build a shared library.
libmylibrary.a is a static lib so you probably should not be using -fPIC
The -lstdc++ indicates you are at least linking against it.
Are you doing a cross compile? Centos 6 should be gcc 4.4.7ish and I thought 
4.9 was Centos 7

.../mylibrary/0.1/gcc-4.9-glibc-2.20/8fd4fe1/lib/libmylibrary.a: error adding 
symbols: Bad value

Hope this helps...

Thanks
cco
_______________________________________________
Libav-user mailing list
[email protected]
http://ffmpeg.org/mailman/listinfo/libav-user

Reply via email to