simple C++ project with vcpkg and cmake: can't run through with installed library


I'm quite new to C++ and its ecosystem, still learning. Recently I'm trying to learn how to install a library and use it in my project.

I'm following the tutorial in the following link:

I'm ok with the basic usage of vcpkg and follow the tutorial install the sqlite3 library.

And also learned the basis stuff of cmake. As the tutorial goes: The best way to use installed libraries with cmake is via the toolchain file. So I prepared the following CMakeLists.txt:

cmake_minimum_required(VERSION 3.0)

set(CMAKE_TOOLCHAIN_FILE "C:/Develop/test/cpp/test-vcpkg/vcpkg/scripts/buildsystems/vcpkg.cmake")


set(sqlite3_DIR "C:/Develop/test/cpp/test-vcpkg/vcpkg/installed/x64-windows/share/sqlite3")

find_package(sqlite3 CONFIG REQUIRED)

add_executable(main main.cpp)

target_link_libraries(main sqlite3)

my CMakeLists.txt is a little different from the one in the tutorial, I set the sqlite3_DIR which is not mentioned in the tutorial (if I didn't add it, the build process will fail.)

And the source file is quite simple as following:

#include <sqlite3.h>
#include <stdio.h>

int main()
    printf("%s\n", sqlite3_libversion());
    return 0;

And I run the build command as the tutorial shows:

cmake .. 

cmake --build .

these two command run through without errors.

I try to open the .sln file generated in the cmake .. process with visual studio, and try to build it, got the following error:

The application was unable to start correctly(0xc000007b)

If I try to the executable file of main.exe which I get during the cmake --build . process. I will get the same error message window.

Any help or ideas?

asked on Stack Overflow Aug 27, 2019 by Chris Bao • edited Aug 27, 2019 by Chris Bao

0 Answers

Nobody has answered this question yet.

User contributions licensed under CC BY-SA 3.0