Any difference in linking with gcc vs. g++?

前端 未结 3 677
心在旅途
心在旅途 2020-12-11 17:08

Are there any differences in the linking process between gcc and g++?

I have a big C project and I just switched part of the code to C++. The code isn\'t using std C

3条回答
  •  隐瞒了意图╮
    2020-12-11 17:12

    I think that the g++ linker will look for the CPP mangled function names, and it is different from the C ones. I'm not sure gcc can cope with that. (Provided you can explicitly use the C version rather than the C++ one).

    Edit:

    It should work if you have

    extern "C" {
    
    }
    

    in your code and the object file has been compiled with g++ -c. But I won't bet on this.

提交回复
热议问题