Setup a C project

Hi.

I've tried to setup a simple C project but I don't understand how. When I create a new project it always generates a C++ project.

Not really easy to understand what I have to do with the CMakeLists.txt file I have to say. I'm just lost right now.

I've a set up a github repository at https://github.com/Vadorequest/Projet-C-Exia-2014/tree/Clion
Would you like to help me to get started with this IDE?

Thanks.

0
13 comments
Avatar
Permanently deleted user

Any support?

0

Hi,

Sorry for the delay. Yes, you're right, currently our 'New project' wizard creates only C++ project. If you want to create project base on your sources please use 'Import project' action and check all neccessary sources from the list. It will create CMakeLists.txt according to list of selected source files.

0
Avatar
Permanently deleted user

Okay, I'm gonna give a try, thanks for hint. Looking forward to get a good IDE. Keep up the good work love your tools!

0
Avatar
Permanently deleted user

I've followed your advice, I was able to setup a C project, thanks.

But I have some issues, the program doesn't work like it should.

Here is some code

     printf("1 - Jouer\n");

     printf("2 - Charger une partie existante\n");

     printf("3 - Options\n");

     scanf("%d", &choix);

If I remove the scanf, the printf works. If I don't, the console shows nothing.

How am I supposed to make the IDE console work as an expected shell would?

Also, is it possible to have the binary file generated? (executable) so we can try it ourself without being in the IDE context?

Thanks for your help.

Source code: https://github.com/Vadorequest/Projet-C-Exia-2014/blob/Clion/menu.c

0

It's a know issue, you can vote for it so it might get fixed sooner. Regarding path to binary, please copy to terminal the following path from Run/Dubug console like on the top of the screenshot. Btw, in the closest update will be the option in menu to show generated Cmake files (including program binary) in file browser.



Attachment(s):
console-issue.png
0
Avatar
Permanently deleted user

Thanks for pointing me to the right issue, I've upvoted.

About the path, thanks for hint as well, but I cannot execute the binary file:

vadorequest@ubuntu:~/.clion10/system/cmake/generated/6617c260/6617c260/Debug0$ ls -l

-rw-rw-r-- 1 vadorequest vadorequest 12184 Dec 12 23:08 CMakeCache.txt
drwxrwxr-x 5 vadorequest vadorequest  4096 Dec 13 22:21 CMakeFiles
-rw-rw-r-- 1 vadorequest vadorequest  1713 Dec 12 23:06 cmake_install.cmake
-rw-rw-r-- 1 vadorequest vadorequest  8728 Dec 12 23:08 Makefile
-rwxrwxr-x 1 vadorequest vadorequest 18406 Dec 13 22:14 Projet_C_Exia_2014
-rw-rw-r-- 1 vadorequest vadorequest  6225 Dec 12 23:08 Projet_C_Exia_2014.cbp


vadorequest@ubuntu:~/.clion10/system/cmake/generated/6617c260/6617c260/Debug0$ . Projet_C_Exia_2014
bash: .: Projet_C_Exia_2014: cannot execute binary file
How am I supposed to run the file? It's tagged ad "x", so it should be executable but it doesn't work. I'm not used to run files on Ubuntu, more used to Windows :/
0

I beleive you should execute the following

./Projet_C_Exia_2014

0
Avatar
Permanently deleted user

Indeed! Thanks :)

0
Avatar
Permanently deleted user

I need to printf and scanf correctly in the IDE console or it slows down the debug too much :/
Hope there will be a usable 1.0 version soon.

0

I understand your concern, can assure you that we're working hard to polish our CLion as much as possible before 1.0 :)

0
Avatar
Permanently deleted user

Thought I'd add a reply to the original post rather than start a new thread, considering I am about to make the same point.
I am new to C programming and am about to start learning, so I do not have any projects to import or repositories.
What I want to do is be able to start a new C project from scratch, but like the OP I always have a C++ project being automatically generated.
Currently we are into version 1.0.3 and thought there must be a way to achieve this by now.  I'm not sure if I haven't done something I was supposed to during the initial setup, or if there is something I'm neglecting to do now,
but is there a way to choose between C and C++ when I'm creating a new project?
How do I go about writing projects in C using Clion?

0

Hi Gary.

Clion doesn't allow you to create a C project automatically.
So you need to create a new project and change file extensions manually.
Sorry for the inconvenience.

0

We've added C project template in CLion 2016.3.2 EAP. Please, read more details in our blog: https://blog.jetbrains.com/clion/2016/12/clion-2016-3-2-eap/#prj_templates. Your feedback is more than welcome!

0

Please sign in to leave a comment.