0

I'm new to CMake and also new to compiling mixed source, I have received the following errors while trying to compile using CMake and Visual Studio 14.0

(Link target) -> main.obj : error LNK2001: unresolved external symbol ethash_get_cachesize main.obj : error LNK2001: unresolved external symbol ethash_get_datasize

The layout of my project is like this:

I have ethash_get_cachesize and ethash_get_datasize defined in internal.c in a directory ethminer/libethash/ these are C source. im sure that the CMake file that came with this set of sources is ok as the project has compiled before without issue, it has only given me LINK problems after i have added the following:

I have another directory /ethminer/dag/ with a C++ source "dag.cpp" and "dag.h" these are both C++ files. and the CMake file.

set(SOURCES
    DAG.h DAG.cpp
)

include_directories(BEFORE ..)

link_directories(BEFORE ..)

the C++ source file "dag.cpp" includes #include <libethash/internal.h>

however I fear that I am missing something to tell CMake or Visual Studio to find the files it needs from the directory containing "internal.c"

any help would be much appreciated

drescherjm
  • 10,365
  • 5
  • 44
  • 64
  • I see no command which **links** with a library, compiled from "internal.c". If you look for a way how to do this, see [that question](https://stackoverflow.com/questions/8774593/cmake-link-to-external-library). You also may find useful question https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix, which describes possible reasons of "unresolved symbol" error. – Tsyvarev Jun 26 '18 at 23:38
  • Thanks @Tsyvarev , im really struggling with this, 2 days of trying to get this unresolved external working, i dont understand im doing wrong here, i have included the line `target_link_libraries(dag ethash)` in my CMake file, but now i have Cmake throwing errors.. im really frustrated, i cant seem to find any real examples on the internet how to make sure something is linking using CMake.. any help ?? – Why_Is_This_Hard Jun 28 '18 at 02:23
  • `but now I have Cmake throwing errors` - Show that errors. – Tsyvarev Jun 28 '18 at 08:11

0 Answers0