I've read a number of posts concerning similar issues but I still can't find the solution to the following problem.
I have two CLion (OS Windows) projects mylib and myexe which reside in separate directories at the same level. mylib consists of two files: library.h
void hello();
and library.cpp
#include "library.h"
#include <iostream>
void hello() {
std::cout << "Hello, World!" << std::endl;
}
The CMakeLists.txt for mylib is the following:
cmake_minimum_required(VERSION 3.16)
project(mylib)
set(CMAKE_CXX_STANDARD 14)
add_library(mylib SHARED library.cpp library.h)
Next, the project myexe consists of one file main.cpp
#include "../mylib/library.h"
int main() {
hello();
return 0;
}
with the following CMakeLists.txt file
cmake_minimum_required(VERSION 3.16)
project(myexe)
set(CMAKE_CXX_STANDARD 14)
add_executable(myexe main.cpp)
find_library(RESULT mylib "d:/src/test/mylib/cmake-build-debug")
target_link_libraries(myexe "${RESULT}")
Both projects are built without errors. But when I run myexe, the "Hello, world" isn't printed, and I'm getting the following:
Process finished with exit code -1073741515 (0xC0000135)
Please help me, how to solve this issue and link DLL correctly.