jeudi 1 décembre 2016

I want to import the ocilib, how to edit the CMakeLists.txt?

My project directory structure. The ocilib download from "http://ift.tt/2fYrFRf".

MyProject
    ├──CMakeLists.txt
    ├──main.cpp
    |       
    ├───include
    |     ├──ocilib.h
    |     ├──ocilib.hpp
    |     ├──ocilib_core.hpp
    |     └──ocilib_impl.hpp
    |       
    └───lib
          ├──ociliba.dll
          ├──ociliba.lib
          ├──ocilibw.dll
          └──ocilibw.lib

MyProject/main.cpp ->

//Ref. http://ift.tt/2gFY0uy
#include "ocilib.hpp"

using namespace ocilib;

int main(void) {
    Environment::Initialize();
    // ...
    return EXIT_SUCCESS;
}

I refered the ocilib "Readme.txt" file, write the cmake configuration. But when I build the project, the CLion IDE report error like:

 - "make[2]: *** No rule to make target 'CMakeFiles/ocilib.dir/build'.  Stop."
 - "make[1]: *** [CMakeFiles/Makefile2:105: CMakeFiles/ocilib.dir/all] Error 2"
 - ...

or

 - /cygdrive/c/WorkSpace/C/MyProject/include/ocilib_impl.hpp:126: undefined reference to 'OCI_GetLastError'
 - /cygdrive/c/WorkSpace/C/MyProject/include/ocilib_impl.hpp:126:(.text+0x430): relocation truncated to fit: R_X86_64_PC32 against undefined symbol 'OCI_GetLastError'
 - ...

MyProject/CMakeLists.txt ->

cmake_minimum_required(VERSION 3.6)
project(MyProject)
set(CMAKE_CXX_STANDARD 11)
set(INCLUDE_DIR include)
set(LIBRARY_DIR lib)
#add ocilib/include folder
include_directories(${INCLUDE_DIR})
#add ocilib/lib folder
include_directories(${LIBRARY_DIR})
add_subdirectory(include)
add_library (ocilib STATIC lib/ocilibw.lib)
add_executable(MyProject main.cpp)
TARGET_LINK_LIBRARIES(MyProject lib/ocilibw.lib)

I want to build the project with cmake, how to edit the CMakeLists.txt? please help me!

Aucun commentaire:

Enregistrer un commentaire