0% found this document useful (0 votes)
24 views1 page

Stackoverflow Com Questions 43811569 Cmake Target Include Directories Cant Find Header Files

The document discusses an issue where CMake's target_include_directories function is not finding header files even though the exact absolute path to the header files has been provided. The asker is developing on Windows 10 using MinGW-w64 g++ compiler and has included the header and library paths in their CMake file but compilation errors occur because the headers cannot be found.

Uploaded by

upreti2688
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views1 page

Stackoverflow Com Questions 43811569 Cmake Target Include Directories Cant Find Header Files

The document discusses an issue where CMake's target_include_directories function is not finding header files even though the exact absolute path to the header files has been provided. The asker is developing on Windows 10 using MinGW-w64 g++ compiler and has included the header and library paths in their CMake file but compilation errors occur because the headers cannot be found.

Uploaded by

upreti2688
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

About Products For Teams Search… Log in Sign up

CMake: target_include_directories() can't find header files Ask Question

Asked 6 years, 10 months ago Modified 6 years, 10 months ago Viewed 16k times

At the top of my main.cpp file, No such file or directory is thrown at #include


The Overflow Blog
<sqlite3.h> .

7 Controlling cloud costs: Where to start,


Building the code manually by g++ -I"C:\Libraries\64_bit\SQLite3\include\" - and where to go from there
L"C:\Libraries\64_bit\SQLite3\bin\" -lsqlite3 main.cpp Class1.cpp Class1.h sponsored post
Class2.cpp Class2.h -o main throws no errors.
Will antitrust suits benefit developers?

CMake cannot seem to find the header, even though I've explicitly described where it is located in
Featured on Meta
my file-system. According to the documentation for target_include_directories() , that should
be enough: New Focus Styles & Updated Styling for
Button Groups

Specified include directories may be absolute paths or relative paths. Repeated calls for Upcoming initiatives on Stack Overflow
the same append items in the order called. and across the Stack Exchange network

Staging Ground is coming back and


moving out of beta
Why is the target_include_directories() function not finding the headers, even though
I've provided the exact absolute path? Temporary policy: Generative AI (e.g.,
ChatGPT) is banned
I'm developing on a 64-bit Windows 10 machine, and CLion is set-up to compile with the MinGW-
w64 g++ compiler. Related
I've downloaded the 64-bit Windows pre-compiled binary, sqlite3.dll and stored it locally Cmake CHECK_INCLUDE_FILES not
4
in C:\Libraries\64_bit\SQLite3\bin\ . finding header file

In order to access SQLite C++ functions I've also downloaded SQLite3's amalgamated source 71
CMake: target_include_directories() prints
an error when I try to add the source
code and stored all source files in C:\Libraries\64_bit\SQLite3\include\ . directory itself, or one of its subdirectories

I built my project in CLion, which is essentially a fancy GUI-wrapper for CMake. In my 4


CMake not finding proper header/include
files in include_directories
CMakeLists.txt , I've included SQLite3's headers and linked sqlite3 as follows:
10
Cannot find a header with
'include_directories' in CMake
cmake_minimum_required(VERSION 3.7)
project(My_Project) CMake target_include_directories does not
2
find #include of private header
set(CMAKE_CXX_STANDARD 11)
1 CMake source files cannot find header files
set(INCLUDE_DIRS C:\\Libraries\\64_bit\\SQLite3\\include\\)
set(LIBRARIES sqlite3.dll) 1
CMake: can't find my header file in a
# My project's source code different directory
set(SOURCE_FILES main.cpp Class1.cpp Class1.h Class2.cpp Class2.h)
1
CMake include_directories does not help to
find header files
add_executable(My_Project ${SOURCE_FILES})
0 CMake can't find header file
# For compiler warnings
target_compile_options(My_Project PRIVATE -Wall) compiler can't find header file on pre-build
0
# Including SQLite3's headers stage with target_include_directories
target_include_directories(My_Project PRIVATE ${INCLUDE_DIRS})
# Linking against sqlite3.dll
target_link_libraries(My_Project ${LIBRARIES}) Hot Network Questions
Should a footnote number be placed after a
plural's S?
c++ cmake clion
Asked to cite papers for money

Execute two statements with a small difference


Share Improve this question Follow edited May 5, 2017 at 19:17 asked May 5, 2017 at 18:25 between them

Vladislav Martin What should be the standard procedure for


1,564 2 15 34 covering the expense in the case of independent
research publications for a PhD student?

Can you cast Sanctuary through total cover?

1 CMake uses / as directory separator internally. Can you try with that instead of `\`? Is the age of the Earth in the novel "The
– Angew is no longer proud of SO May 5, 2017 at 18:34 Hitchhiker's Guide to the Galaxy" 10 million years?

@Angew Just tried that, it didn't change anything. Still, good to know - I assumed the file separator would be Can a Nova occur outside of a binary star system?

system-dependent. – Vladislav Martin May 5, 2017 at 18:36 Is there a way to stop students using AI to
generate essays?
The whole point of using CMake is to be system-independent. – Angew is no longer proud of SO May 5,
Link command in terminal vs ln vs symbolic link (ln
2017 at 18:37
-s) differences between them?
1 If in the background CMake produces a Makefile, try VERBOSE=1 make to see which command is being How to disclose previous job being terminated
called. Also, try setting your path for INCLUDE_DIRS between quotes " – oLen May 5, 2017 at 19:40 without cause (because of high level security
clearance)
1 It's because cmake is a horrid piece of trash, Same problem, two years ago, never worked after playing 20
Why Don't Electrons "Try" to Flow in an Open
questions on here. Ditched it completely. All better. (Double quotes didn't work for me) – BadZen Mar 17, Circuit?
2021 at 21:16
How to install a curtain rod with a perpendicular
Show 4 more comments wall on one side

Why might an auction go 1NT-3NT?

1 Answer Sorted by: Highest score (default) In The Shadow of the Torturer, the torturers live in
a tower made from metal. Is it ever stated that this
tower is a long disused spaceship?
You can run into problems if you don't put paths between quotes. Exhaustion by compact sets eventually include
fixed compact set.
Thus it is a good idea to write:
6 What is this celestial phenomenon in the video?

What are my options for encrypting a mac server


set(INCLUDE_DIRS "C:\\Libraries\\64_bit\\SQLite3\\include\\") but having it be able to reboot automatically after a
power failure?

or, rather: How to make expression-dependent


replacements?

Is this a valid "easy" proof that two free groups are


set(INCLUDE_DIRS "C:/Libraries/64_bit/SQLite3/include/") isomorphic if and only if their rank is the same?

Paraphrasing when citing


Additionally, the CMakeLists.txt as it currently stands won't be able to find -lsqlite3 . Are millennials and generation Z more politically
Thankfully, CMake makes finding libraries easy: conscious than previous generations?

Output of OR-gate when inputs are active but gate


is not powered
# Optionally, add 'PATHS "C:/Libraries/64_bit/SQLite3/bin/"'
find_library(SQLITE3_LIBRARY NAMES sqlite3) Redundancy due to Organisational Restructure

Capacitance on floating terminals of a multimeter


If the library is discover-able on your system, the above command will return the path to the library
and store that path in SQLITE3_LIBRARY . All that remains to do is link the project against the Question feed

SQLite3 library:

# Link project to the SQLite3 library


target_link_libraries(MSP_Tool ${SQLITE3_LIBRARY})

Share Improve this answer Follow edited May 5, 2017 at 20:36 answered May 5, 2017 at 20:22
Vladislav Martin oLen
1,564 2 15 34 5,327 1 35 49

Edited to include the additional bit I figured out on how to find the .dll now that the header files are taken
care of (as per your answer, which is all my question asked for). Accepted :) – Vladislav Martin May 5,
2017 at 20:30

I've been messing with CMake for 2 days and all I missed was just double-quotes!? Thank you man!!!
– offchan Apr 18, 2019 at 9:23

Add a comment

Your Answer

Sign up or log in Post as a guest


Name
Sign up using Google

Sign up using Facebook Email


Required, but never shown

Sign up using Email and Password

Post Your By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our
Answer privacy policy.

Not the answer you're looking for? Browse other questions tagged c++ cmake clion or ask
your own question.

STACK OVERFLOW PRODUCTS COMPANY STACK EXCHANGE NETWORK Blog Facebook Twitter LinkedIn Instagram

Questions Teams About Technology


Help Advertising Press Culture & recreation
Collectives Work Here Life & arts
Talent Legal Science
Privacy Policy Professional
Terms of Service Business
Contact Us
API
Cookie Settings
Data Site design / logo © 2024 Stack Exchange Inc; user
Cookie Policy contributions licensed under CC BY-SA. rev 2024.3.28.7077

You might also like