How to include "graphics.h" header file in C ?

已回答

As i include , "graphics.h" header file in  c , it shows no such file exist.

2

Please use include_directories command in your CMakeLists.txt. Please find out more in our web help: https://www.jetbrains.com/help/clion/2016.3/quick-cmake-tutorial.html.

0

Please use the following command in your CMakeLists.txt:

include_directories(<path_to_the_folder_where_your_header_is>)

and reload CMake after that.

0

When you say "path", I suppose you don't mean "C:\MinGW\include\graphics"? Because apparently the backslashes are creating a problem in CMake.txt.

 

0

@Canestis please use double backslashes, like this:

include_directories("C:\\MinGW\\include\\graphics")
1

@Anna Falevskaya Many thanks! The library is now included! However another problem came up.

When I try to compile a code, which is 100% correct and working on other systems and/or IDEs, these errors show up (look at attachment). Any ideas?

0

@Canestis I assume you need to include a related library to your project. Please try adding the following line in the CMakeLists.txt file after add_executable() command:

target_link_libraries (<target_name> <path_to_the_folder_where_the_library_is>)
0

Anna Falevskaya I tried doing this as you said, but it still gives me an error.

 

See attached

1

Iceman1337

  1. Change add_executable(main.cpp) to add_executable(Graphics main.cpp).
  2. Change your target_link_libraries(...) command to target_link_libraries(Graphics "D:\\JetBrains\\CLion\\MinGW\\mingw32\\lib\\libbgi.a") (assuming that you're sure that this library is the one you need)

And please read https://www.jetbrains.com/help/clion/quick-cmake-tutorial.html.

1

Anna Falevskaya

 

tried that, still not working.

1

Iceman1337 for some reason CMake can't link your libbgi.a library. I'd suggest checking whether it actually exists in the specified path.

Please note that these kind of questions are out of scope of CLion support, since they are just regular CMake issues not related to CLion.

0

thanks to all of you, the code works perfectly fine, but it does not create the window to see the circles and stuff, is there any other setting IN Clion that has to be tweaked? or it should work fine in the first place

 

0

请先登录再写评论。