Hello,
I’m pretty new to C++ and Unreal Engine itself. I decided to follow the Unreal Engine YouTube tutorial: C++ Tutorial Tanks vs Zombies. Everything went well until I reached part 3 of the series.
At first I had the error: Cannot open source file ClassName.generated.h. I have no idea how, but it was suddenly fixed. Now I get 2 new errors whenever I try to compile the project.
Error:
I see an error that says: already defined in IceGirl.cpp.obj. So here’s the code of the classes.
Number 1:
Number 2:
I have absolutely no idea what the 2nd error means and I can’t seem to figure it out.
You got some linker errors but you posted incomplete message. This linker error suggest that you for duplicate definition of function somewhere and linker is confused which one to use. This commonly appens if that extra definition is made by UHT in .generated.h
Do following things:
- Close editor
- Open sln file in your project directory
- Rebuild the solution or at least your module project
This will rebuild your entire code in most purest form (this could possibly fix your problem too), if this does not success post full contence of output tab (no screenshots, copy paste with code formatting, and please don’t post anything from error list as it never gives complete view of situation).
You could also try more radical method if rebuild won’t work of deleting Intermediate forder and regenerating VS project files (you need to do it as some VS files are generated there) and building the solution.
Remember to do all that with editor close as hot reload loves to mess up things sometimes too.
Before doing that you might consider doing backup of your Bineries forder in project directory as this process will delete all dlls from it and without dlls you would be able to open the project. You will need to successfully compile it once again to create new dlls.
Thank you for your reply!
I did the first thing that you said. Rebuilding the solution and module project and this is what I got from the Output Tab (attachted a txt file).
I did the 2nd method you suggested and it also didn’t work. I received the same error as my post. I have no idea what to do or how to solve it. I need this project to work since it’s for something important.
link text
Ok
IceGirlStatics.cpp.obj : error LNK2005: "public: static bool __cdecl UIceGirlStatics::FindLookAtAngle2D(struct FVector2D const &,struct FVector2D const &,float &)" (?FindLookAtAngle2D@UIceGirlStatics@@SA_NAEBUFVector2D@@0AEAM@Z)already defined in IceGirl.cpp.ob
j
Suggest that you have same function UIceGirlStatics::FindLookAtAngle2D with same argument set defined (“Function definition” in C++ terminology mean code written for function like in screen number 2) in IceGirlStatics.cpp and IceGirl.cpp. Since all cpp files are compiled individually compiler dont know if function code it compiles is also defined somewhere else, so the issue arrise on linking stage where all object files (CPU machine code generated for individual cpp file) are combined, linker see 2 definitions of same function and don’t know which one to use
Check the includes in IceGirl.cpp if you didn’t incidently include some cpp file, or defined code in header file. Note that there no difference between cpp and h files they both C++ code just with different roles, cpp files can be included and code can be written in header files too, but then when you include that header you pasting extra definition to the file. Also make sure oyu have #pragma once
in all you header files. Whatever issue is it definitly sit in IceGirl.cpp, thats for sure
Linking errors like that can also apper if you gonna use BlueprintImplementableEvent or BlueprintNativeEvent (there also some other specifiers that does that), UHT in those cases generates definition for those functions, so if you defined those functions in your cpp file then it will also throw that linker error. But in those cases error should point to *.generated.cpp