Как встраивать asmjit в собственный проект C ++?

Я новичок в asmjit (и несколько новичок в C ++), и сейчас я пытаюсь заставить asmjit работать в моем проекте C ++. Я использую машину Windows с Visual Studio 17 и C ++ 17, и моя первая попытка использования cmake уже работала нормально.

Тем не менее, я бы предпочел встроить asmjit в свой проект, как это было предложено Вот (см. раздел Настройка & Сборка, первый абзац). Как описано там, я просто скопировал src каталог в каталог моего проекта и определил ASMJIT_EMBED а также ASMJIT_STATIC флаги (хотя я знаю, что достаточно только одного, но это ничего не меняет). Затем я попробовал очень простой тест следующим образом:

#define ASMJIT_EMBED              // Asmjit is embedded (implies ASMJIT_STATIC).
#define ASMJIT_STATIC             // Define to enable static-library build.

#include "src\asmjit\asmjit.h"
int main(int argc, const char* argv[])
{
asmjit::X86Xmm var1;
}

Код компилируется нормально, однако компоновщик продолжает бросать unresolved externals ошибки:

1>------ Build started: Project: Project2, Configuration: Debug Win32 ------
1>main.cpp
1>d:\eig\arbeit\local_forschung\project2\src\asmjit\base\operand.h(1500): warning C4804: '~': unsafe use of type 'bool' in operation
1>d:\eig\arbeit\local_forschung\project2\src\asmjit\base\operand.h(1527): note: see reference to class template instantiation 'asmjit::TypeIdOfInt<bool>' being compiled
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\filesystem(2447): note: see reference to class template instantiation 'std::chrono::time_point<std::filesystem::_File_time_clock,std::filesystem::_File_time_clock::duration>' being compiled
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\type_traits(520): note: see reference to class template instantiation 'std::basic_string_view<wchar_t,std::char_traits<wchar_t>>' being compiled
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\type_traits(1358): note: see reference to class template instantiation 'std::is_convertible<const _StringViewIsh &,std::basic_string_view<wchar_t,std::char_traits<wchar_t>>>' being compiled
1>        with
1>        [
1>            _StringViewIsh=const wchar_t *
1>        ]
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\type_traits(1364): note: see reference to class template instantiation 'std::conjunction<std::is_convertible<const _StringViewIsh &,std::basic_string_view<wchar_t,std::char_traits<wchar_t>>>,std::negation<std::is_convertible<const _StringViewIsh &,const _Elem *>>>' being compiled
1>        with
1>        [
1>            _StringViewIsh=const wchar_t *,
1>            _Elem=wchar_t
1>        ]
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\xstring(2105): note: see reference to variable template 'const bool conjunction_v<std::is_convertible<wchar_t const * const &,std::basic_string_view<wchar_t,std::char_traits<wchar_t> > >,std::negation<std::is_convertible<wchar_t const * const &,wchar_t const *> > >' being compiled
1>c:\program files (x86)\microsoft visual studio\2017\community\vc\tools\msvc\14.14.26428\include\xstring(2264): note: see reference to alias template instantiation '_Is_string_view_ish<const wchar_t*>' being compiled
1>d:\eig\arbeit\local_forschung\project2\src\asmjit\base\operand.h(1500): warning C4804: '<': unsafe use of type 'bool' in operation
1>   Creating library D:\eig\Arbeit\local_Forschung\Project2\Debug\Project2.lib and object D:\eig\Arbeit\local_Forschung\Project2\Debug\Project2.exp
1>main.obj : error LNK2001: unresolved external symbol "struct asmjit::X86OpData const asmjit::x86OpData" (?x86OpData@asmjit@@3UX86OpData@1@B)
1>D:\eig\Arbeit\local_Forschung\Project2\Debug\Project2.exe : fatal error LNK1120: 1 unresolved externals
1>Done building project "Project2.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

Возможно, я делаю что-то ужасно неправильно — но что это?

1

Решение

Основано на комментарии orhtej2

Вам также необходимо добавить файлы, которые вы скопировали, в решение / проект, чтобы MSVS фактически создала их.

вот что я сделал: просто щелкните правой кнопкой мыши на проекте ==> Добавить ==> Существующий элемент, а затем выберите все исходные файлы из каталогов asmjit. Это работало нормально.

0

Другие решения

Других решений пока нет …