0

I have already put libmysql.lib and libmysql.dll files in cmake-build-debug folder enter image description here

and written my CMakeLists.txt like this

\`cmake_minimum_required(VERSION 3.21)


project(Project_Demo)

set(CMAKE_CXX_STANDARD 14)

include_directories(“C:\\Program Files\\MySQL\\MySQL Server 8.0\\include”)


link_directories(“C:\\Program Files\\MySQL\\MySQL Server 8.0\\lib”)


link_libraries(libmysql)

add_executable(Project_Demo Demo.cpp)

target_link_libraries(Project_Demo libmysql)\`.

However, I still can't find the mysql headfiles.

I search on Google but can't find the answer. I am not a native English speaker, so I apologise if I have any grammer or spelling mistakes above.

Gerhardh
  • 11,688
  • 4
  • 17
  • 39
  • 1
    Welcome to SO. Is that your real content of the `CMakeLists.txt`? There are illegal characters: `“...”`. These are not correct quote characters. It seems as if you created that file in a text program like Word or similar. They have the habbit to add typographic quotes. You should copy the text to a text-onle editor and save with standard `"`. – Gerhardh Mar 30 '22 at 08:58
  • Your include and library path are included in quotes. Yor file names are not while they also contain spaces. In general it is not the best idea to use file names with spaces. If you really need to, you should include them in quotes as well. – Gerhardh Mar 30 '22 at 09:00
  • Does this answer your question? [mysql.h file can't be found](https://stackoverflow.com/questions/14604228/mysql-h-file-cant-be-found) – Luuk Mar 30 '22 at 09:25
  • @Gerhardh thanks a lot, your comments really helped me. the space in the path might be the problem. i download a mysql-connector-c ,then put it in another folder without space in it's path . and it seems works, now i can use mysql.h . – yangshford Mar 30 '22 at 10:31

1 Answers1

0

Clion 2022.2 running on win10-64bit, using wsl gcc, the following is my Cmakelists.txt, there are files in the path, I saw the answer saying that quotation marks cannot be used and the path contains spaces, I am satisfied here.

but clion still has an error reminder that the mysql.h file cannot be found. The same is true for a new project.

cmake_minimum_required(VERSION 3.16)
project(untitled C)

set(CMAKE_C_STANDARD 99)

include_directories(D:\\MySQL\\MySQLServer8\\include)
link_directories(D:\\MySQL\\MySQLServer8\\lib)
link_libraries(libmysql)

add_executable(untitled main.c)

target_link_libraries(untitled libmysql)
steve lee
  • 1
  • 1