c++ - Undefined reference to an assembly function -


an assembly function called c++ program

my simple assembly code (1.s)

.align 4 .code 32            .globl testfunc  .func   testfunc:           bx lr          .endfunc  .end 

c++ code is (1.cpp)

#include <stdio.h> #include <stdlib.h>  extern "c" {     void testfunc(void); }  int main() {    testfunc();    printf("completed\n");    return 0; }   

i compiled assembly code using arm-none-linux-gnueabi-as -o 1.o 1.s

when c++ code compiled arm-none-linux-gnueabi-g++ -o 1c.o 1.cpp getting error

in function main, undefined reference testfunc()

why happening declared testfunc() extern ?

if compilation argument list in form:

arm-none-linux-gnueabi-g++ -o 1c.o 1.cpp 

it means 1.cpp object file output. i'm not sure going in case go linking too. when in form

arm-none-linux-gnueabi-g++ -c 1.cpp 

it means explicity compilation step on file 1.cpp. without linking , resolving dependecies

if there problems linking after use

objdump -t 

on both .o files , check if name of function same. there problems underscores compilators add them not check if function compiled underscore , if not add manually in assembly code


Comments

Popular posts from this blog

google api - Incomplete response from Gmail API threads.list -

Installing Android SQLite Asset Helper -

Qt Creator - Searching files with Locator including folder -