#Projects not compiling (Build error)
1 messages · Page 1 of 1 (latest)
When your question is answered use !solved to mark the question as resolved.
Remember to ask specific questions, provide necessary details, and reduce your question to its simplest form. For tips on how to ask a good question use !howto ask.
- Main is not a class, it's a function
what do you mean? what should i do then?
Somehow, you need to specify that you want to build several different executables, one from each main.c file
Probably this can be done from settings somewhere
Or, by adding a target in some cmakelists file
You can have multiple targets in one cmake project
how can i do that tho?
But the OP has a cmake file for each project.
That works too ofc.
I am confused, btw.
Are you working out how to build all targets?
Or just "butler"?
each main class you see is a seperate project, which i want to compile individually
Okay, that clears that up.
And right now your "butler" project won't build.
Can you share the CMakeLists.txt?
which one ?
This is pure guesswork so please excuse if I am off the mark...
I am guessing that you have configured CLion to use the "Unix Makefile" generator for your projects?
I say this, because
*** target pattern contains no `%'. Stop.
Suggests a problem with the generated make files.
If true, then this is still surprising. I would expect this to have been tested thoroughly by the cmake community.
You could try switching to the "Ninja" generator.
But you may have to install Ninja-build first.
As you are on MACOS, I can provide no guidance other than confirming that Ninja is available on MACOS.
Requires Homebrew??
https://github.com/ninja-build/ninja/wiki/Pre-built-Ninja-packages
im not sure what this means
im on mac tho
cmake_minimum_required(VERSION 3.29)
project(CPS1011-Labs)
add_subdirectory("Lab 1")
add_subdirectory("Lab 2")
cmake_minimum_required(VERSION 3.29)
project("Lab 1")
add_subdirectory("Butler")
add_subdirectory("Feet to Fathoms")
add_subdirectory("Functions")
add_subdirectory("Inventory")
add_subdirectory("Pets")
cmake_minimum_required(VERSION 3.29)
project(Butler C)
set(CMAKE_C_STANDARD 11)
add_executable(Butler main.c)
these are some of my cmakelist files
Just the one for "Butler" please
But it appears this is it?
cmake_minimum_required(VERSION 3.29)
project(Butler C)
set(CMAKE_C_STANDARD 11)
add_executable(Butler main.c)
cmake_minimum_required(VERSION 3.29)
project(Butler C)
set(CMAKE_C_STANDARD 11)
add_executable(Butler main.c)
yep
Not sure how to best to help you along.
I don't have CLion. I wish I did.
I can guide you through building your project from the terminal.
Also not sure how comfortable you are with that.
Plus, even if we got you unstuck on building your project, you still want to be able to do that from CLion.
At least going forward.
I tried a bit using the terminal but tbh i rather not use the terminal ahah.
doing what?
a profiles tab?
I really think I should butt out and let a CLion expert guide you further.
Issue is; they are scarce.
yeah starting to believe the same
im not sure why they are tho
cause clion is quite sleek
No doubt, but it does nom your memory.
ahhh that it does, quite a heavy application....it 4.36gb on its own
If you find that screen I showed you, or something similar, try selecting "Ninja" or "default-ninja" or whatever.
alr thank you
If you have CLion on your system, then my hope is that it also installed Ninja along with it.
hahah I dont really know what that is
is it long and boring enough to learn at uni and have a whole unit about it?
It's part and parcel of cmake.
ohh i see
CMake is not a build system. You cannot build an EXE using CMake alone.
CMake generates a build system that can.
For some lucky people, it can generate project files that you can load directly into your IDE, like Visual Studio.
But for those not so lucky there is Ninja.
Ninja can leverage any compiler you may have and build the EXE.
But you need to tell Ninja what compiler to use.
For someone like me (embedded) I need to provide more instructions to Ninja than you care to learn about today.
But I am guessing that - within CLion - this is all taken care of.
Do you think it has anything to do with this?
Well usually my cmakelists are automatically generated but im not sure why its not doing it anymore
Go into the "CMake" menu at the bottom of "Tools".
What can you see there?
Nah, not it.
What if you right-click on your project in the Project View pane (left of the screen)
Try that.
After all that fuss, this had better work 🤞
You may need to "Clean" your solution though.
Just "Ninja" yes
YAY IT WORKED!!!
Thank God!
You are incredible!!!
thank you so much!
I have been trying to solve this for idk how much time
I am probably more relieved than you.
bahahah im not so sure how it worked but thankfully it worked
haha whys that
Because I was working on pure hunches.
I am still surprised that the "Unix Makefiles" (your default until now) did not work.
But you're better off with Ninja anyway.
So all good.
Thanks again! Ill look deeper to this ninja stuff cause it saved me from doing a bunch of seperate projects and still lost how it functions
If you build from the command line then it's a mere matter of
cmake -G Ninja -B build.dir
building means to add things to my repo?
But, as said, you really want to be able to do builds from within CLion.
I'm not sure what you mean with that.
Are you talking about git repos?
This has nothing to do with those.
oh yeah i was refering to that..... Im really new to this
but our professor assumed we knew all of this
Hah!
has been such a pain. I cant thank you enough honestly
Well, you've learned something.
I learned something.
And you got unstuck.
Happy to have been of help.
Good luck with the rest of the assignment.
Appreciate it!
@warm brook Has your question been resolved? If so, type !solved :)
!solved
Thank you and let us know if you have any more questions!
This thread is now set to auto-hide after an hour of inactivity
@naive horizon I have the same problem again not sure whats happening now. I just tired to create a new folder
everytime i reload it create a cmake-debug folder into excersise 2 for some reason
its also saying that it cannot find a cmake project
ok i managed to fix it since the main.cpp was a .cpp extension and not a .c Still tho for me to be allowed to build i need to create that debug folder and the other mains arent working ;( now
Sorry, was away.
Is the panic over?
mmm not really
dw haha
still getting this error
but for the folder called excerscise 2 it compiles
even tho i re-directed the folder and am on ninja and cleaned the folder
your file is called main.cpp
and its looking for main.c
:)
they are all main.c ;(
I was hallucinating things 
We need to see the CMakeLists.txt file in Exercise 4.
Pure speculation on my part.... that CMakeLists.txt has something like this
project(Exercise4 LANGUAGES C)
#...
add_executable(Exercise3 main.c)
In other words; C&P error.
sorry for the wait....I opened clion again and magicaly everything is working again. im not sure how but it worked.....Could it maybe because I opened a folder before (which is called it github) instead of the project folder
Yeah you need a cmakelist at the root for CLion to work i think
I do have a root cmakelist tho