nodejs / llhttp

Port of http_parser to llparse
http://llhttp.org
Other
1.67k stars 185 forks source link

Problems linking llhttp using g++ or clang++ on Windows. #109

Closed Falven closed 3 years ago

Falven commented 3 years ago

Problem:

I cannot get llhttp to link with either g++ or clang++ on Windows.

MINGW64 /c/source/repos/llhttp (master)
$ mingw32-make --version
GNU Make 4.2.1
Built for x86_64-w64-mingw32
Copyright (C) 1988-2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.

Generating/Building:

I have tried building with the included makefile and also directly with gcc and clang. It builds fine under either. The problem comes up under linking.

MINGW64 /c/source/repos/llhttp (master)
$ mingw32-make
npx ts-node bin/generate.ts
clang  -Os -g3 -Wall -Wextra -Wno-unused-parameter -Ibuild/ -c build/c/llhttp.c -o build/c/llhttp.o
clang  -Os -g3 -Wall -Wextra -Wno-unused-parameter -Ibuild/ -c src/native/api.c -o build/native/api.o
clang  -Os -g3 -Wall -Wextra -Wno-unused-parameter -Ibuild/ -c src/native/http.c -o build/native/http.o
ar rcs build/libllhttp.a build/c/llhttp.o build/native/api.o build/native/http.o
clang -shared build/c/llhttp.o build/native/api.o build/native/http.o -o build/libllhttp.so

MINGW64 /c/source/repos/llhttp (master)
$ ls -R build/
build/:
c/  libllhttp.a  libllhttp.so*  llhttp.h  native/

build/c:
llhttp.c  llhttp.o

build/native:
api.o  http.o

I made a very simple repository here with the generated llhttp.h llhttp.c and llhttp.o

#include "llhttp.h"

int main(int argc, char *argv[])
{
    llhttp_settings_t settings;
    llhttp_settings_init(&settings);
}

clang++ LD Errors

**> Executing task: clang build llhttp.o <**

Starting build...
clang -Os -g3 -Wall -Wextra -Wno-unused-parameter -Isrc/ -c llhttp.c -o llhttp.o
Build finished successfully.

**> Executing task: clang++ build main.cpp <**

Starting build...
clang++ -g .\src\main.cpp .\src\llhttp.o -o .\src\main.exe -v
clang version 12.0.0
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin
 "C:\\Program Files\\LLVM\\bin\\clang++.exe" -cc1 -triple x86_64-pc-windows-msvc19.28.29914 -emit-obj -mrelax-all -mincremental-linker-compatible --mrelax-relocations -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model pic -pic-level 2 -mframe-pointer=none -fmath-errno -fno-rounding-math -mconstructor-aliases -munwind-tables -target-cpu x86-64 -tune-cpu generic -gno-column-info -gcodeview -debug-info-kind=limited -v -resource-dir "C:\\Program Files\\LLVM\\lib\\clang\\12.0.0" -internal-isystem "C:\\Program Files\\LLVM\\lib\\clang\\12.0.0\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.28.29910\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.28.29910\\atlmfc\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\winrt" -fdeprecated-macro -fdebug-compilation-dir "C:\\source\\repos\\llhttp-win" -ferror-limit 19 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.28.29914 -std=c++14 -fdelayed-template-parsing -fcxx-exceptions -fexceptions -faddrsig -o "C:\\Users\\falve\\AppData\\Local\\Temp\\main-1794f8.o" -x c++ ".\\src\\main.cpp"
clang -cc1 version 12.0.0 based upon LLVM 12.0.0 default target x86_64-pc-windows-msvc
#include "..." search starts here:
#include <...> search starts here:
 C:\Program Files\LLVM\lib\clang\12.0.0\include
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29910\include
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29910\atlmfc\include
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt
 C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared
 C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um
 C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt
End of search list.
 "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.28.29910\\bin\\Hostx64\\x64\\link.exe" "-out:.\\src\\main.exe" -defaultlib:libcmt -defaultlib:oldnames "-libpath:C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.28.29910\\lib\\x64" "-libpath:C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.28.29910\\atlmfc\\lib\\x64" "-libpath:C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.19041.0\\ucrt\\x64" "-libpath:C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.19041.0\\um\\x64" "-libpath:C:\\Program Files\\LLVM\\lib\\clang\\12.0.0\\lib\\windows" -nologo -debug "C:\\Users\\falve\\AppData\\Local\\Temp\\main-1794f8.o" ".\\src\\llhttp.o"
clang++: error: linker command failed with exit code 1120 (use -v to see invocation)

main-1794f8.o : error LNK2019: unresolved external symbol llhttp_settings_init referenced in function main
llhttp.o : error LNK2019: unresolved external symbol llhttp__on_message_begin referenced in function llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol llhttp__on_status referenced in function llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol llhttp__on_status_complete referenced in function llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol llhttp__on_url referenced in function llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol llhttp__on_url_complete referenced in function llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol llhttp__on_header_field referenced in function llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol llhttp__on_header_field_complete referenced in function llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol llhttp__on_header_value referenced in function llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol llhttp__on_header_value_complete referenced in function llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol llhttp__before_headers_complete referenced in function llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol llhttp__on_headers_complete referenced in function llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol llhttp__on_chunk_complete referenced in function llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol llhttp__after_headers_complete referenced in function llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol llhttp__on_body referenced in function llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol llhttp__on_message_complete referenced in function llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol llhttp__after_message_complete referenced in function llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol llhttp__on_chunk_header referenced in function llhttp__internal__run
.\src\main.exe : fatal error LNK1120: 18 unresolved externals

Build finished with error(s).
The terminal process failed to launch (exit code: -1).

g++ LD Errors

**> Executing task: gcc build llhttp.o <**

Starting build...
gcc -c llhttp.c -o llhttp.o
Build finished successfully.

**> Executing task: g++ build main.cpp <**

g++ -g .\src\main.cpp .\src\llhttp.o -o .\src\main.exe -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=C:/Program\ Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/lto-wrapper.exe
Target: x86_64-w64-mingw32
Configured with: ../../../src/gcc-8.1.0/configure --host=x86_64-w64-mingw32 --build=x86_64-w64-mingw32 --target=x86_64-w64-mingw32 --prefix=/mingw64 --with-sysroot=/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64 --enable-shared --enable-static --disable-multilib --enable-languages=c,c++,fortran,lto --enable-libstdcxx-time=yes --enable-threads=posix --enable-libgomp --enable-libatomic --enable-lto --enable-graphite --enable-checking=release --enable-fully-dynamic-string --enable-version-specific-runtime-libs --disable-libstdcxx-pch --disable-libstdcxx-debug --enable-bootstrap --disable-rpath --disable-win32-registry --disable-nls --disable-werror --disable-symvers --with-gnu-as --with-gnu-ld --with-arch=nocona --with-tune=core2 --with-libiconv --with-system-zlib --with-gmp=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpfr=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-mpc=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-isl=/c/mingw810/prerequisites/x86_64-w64-mingw32-static --with-pkgversion='x86_64-posix-seh-rev0, Built by MinGW-W64 project' --with-bugurl=https://sourceforge.net/projects/mingw-w64 CFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CXXFLAGS='-O2 -pipe -fno-ident -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' CPPFLAGS=' -I/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/include -I/c/mingw810/prerequisites/x86_64-zlib-static/include -I/c/mingw810/prerequisites/x86_64-w64-mingw32-static/include' LDFLAGS='-pipe -fno-ident -L/c/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/opt/lib -L/c/mingw810/prerequisites/x86_64-zlib-static/lib -L/c/mingw810/prerequisites/x86_64-w64-mingw32-static/lib '
Thread model: posix
gcc version 8.1.0 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) 
COLLECT_GCC_OPTIONS='-g' '-o' '.\src\main.exe' '-v' '-shared-libgcc' '-mtune=core2' '-march=nocona'
 C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/cc1plus.exe -quiet -v -iprefix C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/ -D_REENTRANT .\src\main.cpp -quiet -dumpbase main.cpp -mtune=core2 -march=nocona -auxbase main -g -version -o C:\Users\falve\AppData\Local\Temp\ccunvaaB.s
GNU C++14 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) version 8.1.0 (x86_64-w64-mingw32)
        compiled by GNU C version 8.1.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
ignoring duplicate directory "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++"
ignoring duplicate directory "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32"
ignoring duplicate directory "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward"
ignoring duplicate directory "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/8.1.0/include"
ignoring nonexistent directory "C:/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64C:/msys64/mingw64/lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../include"
ignoring duplicate directory "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed"
ignoring duplicate directory "C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/lib/gcc/../../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include"
ignoring nonexistent directory "C:/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64/mingw/include"
#include "..." search starts here:
#include <...> search starts here:
 C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++
 C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/x86_64-w64-mingw32
 C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include/c++/backward
 C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include
 C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/include-fixed
 C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/include
End of search list.
GNU C++14 (x86_64-posix-seh-rev0, Built by MinGW-W64 project) version 8.1.0 (x86_64-w64-mingw32)
        compiled by GNU C version 8.1.0, GMP version 6.1.2, MPFR version 4.0.1, MPC version 1.1.0, isl version isl-0.18-GMP

GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: 82f0c9785fd37a38ba7b7f8357369a82
COLLECT_GCC_OPTIONS='-g' '-o' '.\src\main.exe' '-v' '-shared-libgcc' '-mtune=core2' '-march=nocona'
 C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/as.exe -v -o C:\Users\falve\AppData\Local\Temp\cci4hRU3.o C:\Users\falve\AppData\Local\Temp\ccunvaaB.s
GNU assembler version 2.30 (x86_64-w64-mingw32) using BFD version (GNU Binutils) 2.30
COMPILER_PATH=C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../libexec/gcc/;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/bin/
LIBRARY_PATH=C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../lib/;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/;C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../
COLLECT_GCC_OPTIONS='-g' '-o' '.\src\main.exe' '-v' '-shared-libgcc' '-mtune=core2' '-march=nocona'
 C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/collect2.exe -plugin C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/liblto_plugin-0.dll -plugin-opt=C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../libexec/gcc/x86_64-w64-mingw32/8.1.0/lto-wrapper.exe -plugin-opt=-fresolution=C:\Users\falve\AppData\Local\Temp\ccYGmbBC.res -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt -plugin-opt=-pass-through=-lpthread -plugin-opt=-pass-through=-ladvapi32 -plugin-opt=-pass-through=-lshell32 -plugin-opt=-pass-through=-luser32 -plugin-opt=-pass-through=-lkernel32 -plugin-opt=-pass-through=-liconv -plugin-opt=-pass-through=-lmingw32 -plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lmoldname -plugin-opt=-pass-through=-lmingwex -plugin-opt=-pass-through=-lmsvcrt --sysroot=C:/mingw810/x86_64-810-posix-seh-rt_v6-rev0/mingw64 -m i386pep -Bdynamic -o .\src\main.exe C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib/crt2.o C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/crtbegin.o -LC:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0 -LC:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc -LC:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib/../lib -LC:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../lib -LC:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../../../x86_64-w64-mingw32/lib -LC:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/../../.. C:\Users\falve\AppData\Local\Temp\cci4hRU3.o .\src\llhttp.o -lstdc++ -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt -lpthread -ladvapi32 -lshell32 -luser32 -lkernel32 -liconv -lmingw32 -lgcc_s -lgcc -lmoldname -lmingwex -lmsvcrt C:/Program Files/mingw-w64/x86_64-8.1.0-posix-seh-rt_v6-rev0/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/8.1.0/crtend.o
C:\Users\falve\AppData\Local\Temp\cci4hRU3.o: In function `main':
C:\source\repos\llhttp-win/./src/main.cpp:6: undefined reference to `llhttp_settings_init'
.\src\llhttp.o:llhttp.c:(.text+0x34a): undefined reference to `llhttp__on_message_begin'
.\src\llhttp.o:llhttp.c:(.text+0x6d4): undefined reference to `llhttp__on_status'
.\src\llhttp.o:llhttp.c:(.text+0x726): undefined reference to `llhttp__on_status'
.\src\llhttp.o:llhttp.c:(.text+0x759): undefined reference to `llhttp__on_status'
.\src\llhttp.o:llhttp.c:(.text+0x77e): undefined reference to `llhttp__on_status_complete'
.\src\llhttp.o:llhttp.c:(.text+0x1b2a): undefined reference to `llhttp__on_url'
.\src\llhttp.o:llhttp.c:(.text+0x1b47): undefined reference to `llhttp__on_url'
.\src\llhttp.o:llhttp.c:(.text+0x1cb7): undefined reference to `llhttp__on_url'
.\src\llhttp.o:llhttp.c:(.text+0x1d68): undefined reference to `llhttp__on_url'
.\src\llhttp.o:llhttp.c:(.text+0x1d8f): undefined reference to `llhttp__on_url'
.\src\llhttp.o:llhttp.c:(.text+0x1e6d): more undefined references to `llhttp__on_url' follow
.\src\llhttp.o:llhttp.c:(.text+0x1e8f): undefined reference to `llhttp__on_url_complete'
.\src\llhttp.o:llhttp.c:(.text+0x1f37): undefined reference to `llhttp__on_url'
.\src\llhttp.o:llhttp.c:(.text+0x1f6a): undefined reference to `llhttp__on_url'
.\src\llhttp.o:llhttp.c:(.text+0x2041): undefined reference to `llhttp__on_url_complete'
.\src\llhttp.o:llhttp.c:(.text+0x27dd): undefined reference to `llhttp__on_header_field'
.\src\llhttp.o:llhttp.c:(.text+0x27f2): undefined reference to `llhttp__on_header_field_complete'
.\src\llhttp.o:llhttp.c:(.text+0x28f0): undefined reference to `llhttp__on_header_value'
.\src\llhttp.o:llhttp.c:(.text+0x290a): undefined reference to `llhttp__on_header_value'
.\src\llhttp.o:llhttp.c:(.text+0x2920): undefined reference to `llhttp__on_header_value_complete'
.\src\llhttp.o:llhttp.c:(.text+0x2975): undefined reference to `llhttp__before_headers_complete'
.\src\llhttp.o:llhttp.c:(.text+0x2983): undefined reference to `llhttp__on_headers_complete'
.\src\llhttp.o:llhttp.c:(.text+0x29b6): undefined reference to `llhttp__on_header_field'
.\src\llhttp.o:llhttp.c:(.text+0x2a81): undefined reference to `llhttp__on_chunk_complete'
.\src\llhttp.o:llhttp.c:(.text+0x2ad2): undefined reference to `llhttp__after_headers_complete'
.\src\llhttp.o:llhttp.c:(.text+0x2b04): undefined reference to `llhttp__on_body'
.\src\llhttp.o:llhttp.c:(.text+0x2b46): undefined reference to `llhttp__on_body'
.\src\llhttp.o:llhttp.c:(.text+0x2b5c): undefined reference to `llhttp__on_message_complete'
.\src\llhttp.o:llhttp.c:(.text+0x2b7d): undefined reference to `llhttp__after_message_complete'
.\src\llhttp.o:llhttp.c:(.text+0x2baa): undefined reference to `llhttp__on_message_complete'
.\src\llhttp.o:llhttp.c:(.text+0x2e32): undefined reference to `llhttp__on_message_complete'
.\src\llhttp.o:llhttp.c:(.text+0x2e8f): undefined reference to `llhttp__on_body'
.\src\llhttp.o:llhttp.c:(.text+0x3036): undefined reference to `llhttp__on_chunk_complete'
.\src\llhttp.o:llhttp.c:(.text+0x3106): undefined reference to `llhttp__on_body'
.\src\llhttp.o:llhttp.c:(.text+0x3144): undefined reference to `llhttp__on_body'
.\src\llhttp.o:llhttp.c:(.text+0x31a2): undefined reference to `llhttp__on_chunk_header'
.\src\llhttp.o:llhttp.c:(.text+0x334a): undefined reference to `llhttp__on_header_value'
.\src\llhttp.o:llhttp.c:(.text+0x33f1): undefined reference to `llhttp__on_header_value'
.\src\llhttp.o:llhttp.c:(.text+0x348e): undefined reference to `llhttp__on_header_value'
.\src\llhttp.o:llhttp.c:(.text+0x35c6): undefined reference to `llhttp__on_header_value'
.\src\llhttp.o:llhttp.c:(.text+0x35e6): undefined reference to `llhttp__on_header_value'
collect2.exe: error: ld returned 1 exit status

Build finished with error(s).
The terminal process failed to launch (exit code: -1).

Also tried the version of clang that comes with VS2019

**> Executing task: clang build llhttp.o <**

Starting build...
clang -Os -g3 -Wall -Wextra -Wno-unused-parameter -Isrc/ -c llhttp.c -o llhttp.o
Build finished successfully.

**> Executing task: clang++ build main.cpp <**

Starting build...
clang++ -g main.cpp llhttp.o -o main.exe -v
clang version 11.0.0
Target: i686-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\Llvm\bin
 "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\Llvm\\bin\\clang++.exe" -cc1 -triple i686-pc-windows-msvc19.28.29914 -emit-obj -mrelax-all -mincremental-linker-compatible -disable-free -disable-llvm-verifier -discard-value-names -main-file-name main.cpp -mrelocation-model static -mframe-pointer=all -fmath-errno -fno-rounding-math -mconstructor-aliases -target-cpu pentium4 -gno-column-info -gcodeview -debug-info-kind=limited -v -resource-dir "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\Llvm\\lib\\clang\\11.0.0" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\Llvm\\lib\\clang\\11.0.0\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.28.29910\\include" -internal-isystem "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.28.29910\\atlmfc\\include" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\Include\\10.0.19041.0\\ucrt" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\shared" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\um" -internal-isystem "C:\\Program Files (x86)\\Windows Kits\\10\\include\\10.0.19041.0\\winrt" -fdeprecated-macro -fdebug-compilation-dir "C:\\source\\repos\\llhttp-win\\src" -ferror-limit 19 -fno-use-cxa-atexit -fms-extensions -fms-compatibility -fms-compatibility-version=19.28.29914 -std=c++14 -fdelayed-template-parsing -fcxx-exceptions -fexceptions -faddrsig -o "C:\\Users\\falve\\AppData\\Local\\Temp\\main-a18907.o" -x c++ main.cpp
clang -cc1 version 11.0.0 based upon LLVM 11.0.0 default target i686-pc-windows-msvc
#include "..." search starts here:
#include <...> search starts here:
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\Llvm\lib\clang\11.0.0\include
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29910\include
 C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise\VC\Tools\MSVC\14.28.29910\atlmfc\include
 C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041.0\ucrt
 C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\shared
 C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\um
 C:\Program Files (x86)\Windows Kits\10\include\10.0.19041.0\winrt
End of search list.
 "C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.28.29910\\bin\\Hostx86\\x86\\link.exe" -out:main.exe -defaultlib:libcmt "-libpath:C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.28.29910\\lib\\x86" "-libpath:C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\MSVC\\14.28.29910\\atlmfc\\lib\\x86" "-libpath:C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.19041.0\\ucrt\\x86" "-libpath:C:\\Program Files (x86)\\Windows Kits\\10\\Lib\\10.0.19041.0\\um\\x86" "-libpath:C:\\Program Files (x86)\\Microsoft Visual Studio\\2019\\Enterprise\\VC\\Tools\\Llvm\\lib\\clang\\11.0.0\\lib\\windows" -nologo -debug "C:\\Users\\falve\\AppData\\Local\\Temp\\main-a18907.o" llhttp.o
clang++: error: linker command failed with exit code 1120 (use -v to see invocation)

main-a18907.o : error LNK2019: unresolved external symbol _llhttp_settings_init referenced in function _main
llhttp.o : error LNK2019: unresolved external symbol _llhttp__on_message_begin referenced in function _llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol _llhttp__on_status referenced in function _llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol _llhttp__on_status_complete referenced in function _llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol _llhttp__on_url referenced in function _llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol _llhttp__on_url_complete referenced in function _llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol _llhttp__on_header_field referenced in function _llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol _llhttp__on_header_field_complete referenced in function _llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol _llhttp__on_header_value referenced in function _llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol _llhttp__after_message_complete referenced in function _llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol _llhttp__on_message_complete referenced in function _llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol _llhttp__on_chunk_complete referenced in function _llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol _llhttp__on_body referenced in function _llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol _llhttp__on_chunk_header referenced in function _llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol _llhttp__after_headers_complete referenced in function _llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol _llhttp__before_headers_complete referenced in function _llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol _llhttp__on_headers_complete referenced in function _llhttp__internal__run
llhttp.o : error LNK2019: unresolved external symbol _llhttp__on_header_value_complete referenced in function _llhttp__internal__run
main.exe : fatal error LNK1120: 18 unresolved externals

Build finished with error(s).
Falven commented 3 years ago

My problem was that I was building llhttp.c without api.o and http.o which is where these unresolved external symbols are located. I was able to link against the libllhttp.a built by make.