. Advertisement .
..3..
. Advertisement .
..4..
I’m building a new program, but when I run it, an error pops up. The error displayed is as follows:
Symbol(s) not found for architecture x86_64
I have tried several workarounds, but they still do not get the desired results. If you have come across this situation and have a solution for the “symbol(s) not found for architecture x86_64” problem, pls let me know.
Here is what I do:
Layer<double> text("pq.txt",0.5,0.5,0.5);
Thanks!
The cause: I think the problem was that it didn’t appear to be possible to separate a templated class into
.cpp
and .h
files.The solution: These following steps will help you to solve this problem:
.cpp
file to the.h
life.h
fileDeclaring that variable (without external) in
.cpp
fileThe error message Qt Creator displays to you is misleading, until you get it figured out. However, it does not stop you from splitting the template class into a header file and an implementation file. This message is worth considering:
The problem, as I initially thought, was that it contains this error in the Issues output. This can lead users to believe that the problem is due the architecture. It’s actually saying that there is a function or a symbol, but no matching implementation was found.
You can see which symbols are missing if you switch from Issues into the Comile Output window. Mine is displayed in red. It is just irritating that the Issues view doesn’t display the details of missing symbols.
This error can be reproduced by simply adding a function definition to a header, and then calling the function from the.cpp files. This will result in something similar to the Issues window.
This is the Compile Output view. Scroll up to see it:
Now we can see that the problem is actually that the function DoSomeStuff of the class PGGui:PGGui is being called using the constructor PGGui.:PGGui. However, the body is missing as the symbol for DoSomeStuff has not been found.