Cross compiling C++ project, Relocations in generic ELF (EM: 3)

前端 未结 2 499
再見小時候
再見小時候 2021-02-09 01:38

I\'ve been working on a c++ project for a while now, but would like to port it over to my arm processor. I already have all of my cross-compile tools (I\'m using CodeSourcery)

相关标签:
2条回答
  • 2021-02-09 02:10

    The problem is you've set your makefile up to link with the new g++ but you haven't changed the compiler you're using to build the objects in the first place.

    The easiest way to fix this is to set environment CXX to the next compiler, i.e.

    export CXX=/home/matt/CodeSourcery/bin/arm-none-linux-gnueabi-g++
    

    or just set it for a given make by adding CXX=... to the command line.

    You'll need to make clean first but you'll then use the correct compiler for both the compile and link.

    You could also specify a new how-to-compile-C++ files rule in your makefile to specify the new compiler but the environment variable is easier:

    .cc.o:
            /home/.../g++ $(CPPFLAGS) $(CXXFLAGS) -c
    
    0 讨论(0)
  • 2021-02-09 02:12

    The problem is because of these three rules:

    Socket: Socket.cpp
    ServerSocket: ServerSocket.cpp
    simple_server_main: simple_server_main.cpp
    

    First of all, the left-hand side of the rule should be the object file I guess, so should have the .o suffix.

    The second problem, and most likely the root of your problem, is that there is no command to compile the source files, which means that make will use the default compiler and not your cross-compiler.

    0 讨论(0)
提交回复
热议问题