+ 19

How to solve linker errors in c++?

28th Aug 2018, 4:56 PM
💞ⓢⓦⓐⓣⓘ💞
💞ⓢⓦⓐⓣⓘ💞 - avatar
6 odpowiedzi
+ 3
Linker errors generally occur due to following reasons: ->Referenced function definition is not found -> .o file is not linked You can start by checking -> the .cpp file has main() -> .o file is linked -> function for which linker error is shown is defined and spelled correctly with correct parameters in the call.
28th Aug 2018, 5:51 PM
Pal
+ 3
Pal I was just saying that if you compile .cc or .cpp files into .o object files and then try to link them all to build an executable which also depend on some static libraries e. g. with a .a extension and different .o files have dependencies on the .a libraries, then where you place the -l switches in the call to gcc e. g. in the Makefiles is important.
29th Aug 2018, 4:53 AM
Sonic
Sonic - avatar
+ 2
Linking libraries to the final executable along with .o files can be a nightmare especially as the order in which these libraries are specified matters.
29th Aug 2018, 1:47 AM
Sonic
Sonic - avatar
+ 1
Monic thanks for sharing. I have used Visual studio... so new for unix based conpilers. Could you please share any other points you know about the question?
29th Aug 2018, 4:45 AM
Pal
+ 1
ok :) thanks
29th Aug 2018, 4:58 AM
Pal
- 1
hello
28th Aug 2018, 6:46 PM
Sunil Ekk
Sunil Ekk - avatar