Gcc, static library, external assembly becomes undefined

I have a problem with g ++ creating an application that references a static library, where the latter should contain some global functions written in external asm files compiled with yasm. So in the library I have

#ifdef __cplusplus
extern "C" {
#endif

extern void __attribute__((cdecl)) interp1( char *pSrc );
extern void __attribute__((cdecl)) interp2( char *pSrc );

#ifdef __cplusplus
}
#endif

which I mention elsewhere in the library. Then the implementation is performed in the asm file, for example:

section .data
; (some data)
section .text
; (some text)

global _interp1
_interp1:
    ; (code ...)
    ret

global _interp2
_interp2:
    ; (code ...)
    ret

Compiling and linking works fine for the library, I do

yasm -f elf32 -O2 -o interp.o interp.asm

and then

ar -rc libInterp.a objs1.o [...] objsN.o interp.o 
ranlib libInterp.a

Now, finally, to link the library to the main application, I do

g++ -O4 -ffast-math -DNDEBUG -fomit-frame-pointer -DARCH_X86 -fPIC -o ../bin/interp this.o that.o -lboost_thread -lpthread ./libInterp.a 

and i get errors

undefined reference to `interp1'
undefined reference to `interp2'

What am I doing wrong here? any help is appreciated.

+3
source share
1 answer

gcc . , .

, , .

, , , , , - :

+2

Source: https://habr.com/ru/post/1757750/


All Articles