Reputation: 163
I am using CLion 2016.1.1 on Ubuntu (16.04)
When I compile my project, the CMake output shows:
/opt/clion/bin/cmake/bin/cmake --build
/home/glapworth/.CLion2016.1/system/cmake/generated/project_name-f43e0982/f43e0982/Debug --target all -- -j 8
[ 33%] Linking C executable
/home/glapworth/src/project/project_name/bin/project_name
However, when I execute:
/opt/clion/bin/cmake/bin/cmake --build /home/glapworth/.CLion2016.1/system/cmake/generated/project_name-f43e0982/f43e0982/Debug --target all -- -j 8
I can see the compiler error:
...
CMakeFiles/project.dir/src/main.c.o: In function `main':
/home/glapworth/src/project/project_name/src/main.c:22: undefined reference to `curl_global_init'
...
How can I get CLion to show the compiler errors or warnings?
Upvotes: 8
Views: 15002
Reputation: 1272
here's bug-report https://youtrack.jetbrains.com/issue/CPP-6559
No, CLion shows all compile errors. You can't compile a project if you have errors.
But, CLion shows notices only once during build time, until you make a clean build, you will not see them again. Because you have already compiled object files and CLion (CMake) will not rebuild them if you haven't changed source files.
CMake assumes you know what your'e doing and does not rebuild all your codebase from scratch, so you don't see notices after the first compile run.
Upvotes: 5
Reputation: 163
It seems that CLion only shows the error on the first compile. If you've accidentally compiled a second time, you'll not be able to see the error output. I've since moved back to vim.
However, if you want to stick with CLion, and you are having the same problem, you can build the Makefile
manually; In the source directory that contains the CMakeLists.txt
cmake .
make
This will allow you to compile on demand from a terminal.
I also tend to set the build directoy to ./bin by editing the CMakeLists.txt
to include the following line
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/bin")
Upvotes: 1
Reputation: 26661
You have to check your CMakeLists.txt
. What does it look like? You can also try and clean your code, tool -> cmake -> refresh (both options) and have a regular Makefile
that your build with so if Clion doesn't inform you about what's wrong then you can build with a regular Makefile
. My CMakeLists.txt
looks like this
cmake_minimum_required(VERSION 2.8.12)
project(project001)
set(CMAKE_VERBOSE_MAKEFILE on)
file(GLOB SOURCES "./*.c")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99 -Wall -pedantic")
add_executable(project001 ${SOURCES})
target_link_libraries(project001 readline)
My Makefile
for the same project is
CC = gcc
GIT_VERSION := $(project001 git describe --abbrev=4 --dirty --always --tags)
CFLAGS := $(CFLAGS) -pedantic -std=c99 -Wall -O3 -ledit -g -DVERSION=\"$(GIT_VERSION)\"
project001: main.o
$(CC) -o project001 main.o errors.c util.c pipeline.c -ledit
main.o: main.c errors.c util.c
.PHONY: clean
clean:
rm -f *.o
If Clion can't compile, then I fix the errors at the prompt and I use Clion to analyze my code so that it compiles without errors, then I can clean the project in Clion and run it from within Clion again.
Upvotes: 0