I can’t remember why I solved it like this. I searched again and didn’t find a similar answer.
Due to the needs of the experiment, I need to compile this example:
https://github.com/grimm-co/GEARSHIFT/blob/trunk/examples/simple.c
However, if you run directly:
gcc simple.c -O0 -o simple
otherwise will report an error:
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/7/../../../x86_64-linux-gnu/Scrt1.o: in function `_start’:
(.text+0x24): undefined reference to `main’
collect2: error: ld returned 1 exit statu
Solution:
Change to
gcc -shared simple.c -O0 -o simple
Just. I suddenly remembered how I solved it. I referred to this: https://github.com/grimm-co/GEARSHIFT/blob/trunk/examples/Makefile
The online solutions are different from this, so here’s a simple record. It’s hard to say that it can help other basin friends.
Read More:
- [Solved] VScode Error: undefined reference to ‘WinMain’ collect2.exe: error: ld returned 1 exit status
- [Solved] error adding symbols: File in wrong format collect2: error: ld returned 1 exit status
- Ubutnu Qt Unable to start process Error: “make“ -f ‘ /usr/bin/ld: cannot find -lGL collect2: error: ld returned 1 exit sta
- VSCode Error: collect2.exe: error: ld returned 1 exit status
- VSCode Error: collect2.exe:error:1d returned 1 exit status [How to Solve]
- Dev C++ Error: error: ld returned 1 exit status [How to Solve]
- [Solved] VsCode + gfortran Compiler Error: error: ld returned 1 exit status
- DevC++ Error: [Error] Id returned 1 exit status [How to Solve]
- [Solved] cortex_M3 freeRTOS Error: undefined reference to `_sbrk‘
- Clion new method shows undefined reference to solution
- error: undefined reference to `calculate()` [How to Solve]
- [Solved] Qt Error: undefined reference to xxxxx
- [Solved] C++ error: undefined reference to `xxx‘
- [Solved] Compile Error: undefined reference to `google::FlagRegisterer::FlagRegisterer
- [Solved] PCL Compile Error: undefined reference to `pcl::PCLBase<pcl::PointXYZRGBA>:: XXX
- C++Qt development – Qtsocket programming error: undefined reference to `_imp__WSAStartup
- [Solved] QT error: error: undefined reference to ` VTable`
- [Solved] Error: The slice reducer for key “auth“ returned undefined during initialization. If the state pas
- NVM use error: exit status [How to Solve]
- [Solved] Rocketmq console connect to x.x.x.x:10911 failed Error