Perlmint / glew-cmake

GLEW(https://github.com/nigels-com/glew, source updated nightly) with Cmake and pre-generated sources
Other
233 stars 95 forks source link

Having trouble with linking glew-cmake\bin\glew-sharedd.dll #67

Open onthegrid007 opened 3 months ago

onthegrid007 commented 3 months ago

Getting an error of no _DllMainCRTStartup function...

[1/2] Linking C shared library vendor\RAITOEngine\vendor\glew-cmake\bin\glew-sharedd.dll
FAILED: vendor/RAITOEngine/vendor/glew-cmake/bin/glew-sharedd.dll vendor/RAITOEngine/vendor/glew-cmake/lib/glew-sharedd.lib
C:\Windows\system32\cmd.exe /C "cd . && C:\PROGRA~1\LLVM\bin\clang.exe -nostartfiles -nostdlib -std=c2x -O0  -fuse-ld=lld-link -shared -o vendor\RAITOEngine\vendor\glew-cmake\bin\glew-sharedd.dll  -Xlinker /MANIFEST:EMBED -Xlinker /implib:vendor\RAITOEngine\vendor\glew-cmake\lib\glew-sharedd.lib -Xlinker /pdb:vendor\RAITOEngine\vendor\glew-cmake\bin\glew-sharedd.pdb -Xlinker /version:2.2 vendor/RAITOEngine/vendor/glew-cmake/CMakeFiles/libglew_shared.dir/src/glew.c.obj  -lopengl32.lib  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lcomdlg32 -ladvapi32 -loldnames  && cd ."
lld-link: error: <root>: undefined symbol: _DllMainCRTStartup
clang: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

Any help would be appreciated...

nigels-com commented 3 months ago

This looks like a Windows build using vanilla clang. _DllMainCRTStartup is usally via the VC runtime in my understanding, perhaps -nostartfiles is a problem here.

onthegrid007 commented 3 months ago

How would I go about removing that flag in the compilation?

Perlmint commented 3 months ago

glew-cmake does not set -nostartfiles flag. In my assumption, It would be set in some Language-wide flags ex) CMAKE_C_FLAGS. Please check CMakeLists.txt of RAITOEngine or the most top CMakeLists.txt or environment variable.

onthegrid007 commented 2 months ago

I have tried everything to remove this flag, it is not me and it is not from RAITOEngine. I als tried building in release and there's an unresolved symbol to memset that comes up as well as the same error from before. I can't seem to figure out why...

Perlmint commented 2 months ago

I could not reproduce your error. I can build libglew_shared with cmake 3.29, clang 11.0 & ninja 1.12 on windows. Also, I found that -nostartfiles is not an issue.

My build log

[1/2] C:\PROGRA~1\LLVM\bin\clang.exe -DGLEW_BUILD -DGLEW_NO_GLU -DVC_EXTRALEAN -DWIN32_MEAN_AND_LEAN -D_CRT_SECURE_NO_WA
RNINGS -Dlibglew_shared_EXPORTS -IC:/Users/perlmint/Documents/glew-cmake/include -g -Xclang -gcodeview -O0 -D_DEBUG -D_D
LL -D_MT -Xclang --dependent-lib=msvcrtd -std=gnu2x -MD -MT CMakeFiles/libglew_shared.dir/src/glew.c.obj -MF CMakeFiles\
libglew_shared.dir\src\glew.c.obj.d -o CMakeFiles/libglew_shared.dir/src/glew.c.obj -c C:/Users/perlmint/Documents/glew-
cmake/src/glew.c
[2/2] C:\WINDOWS\system32\cmd.exe /C "cd . && C:\PROGRA~1\LLVM\bin\clang.exe -nostartfiles -nostdlib -g -Xclang -gcodevi
ew -O0 -D_DEBUG -D_DLL -D_MT -Xclang --dependent-lib=msvcrtd  -fuse-ld=lld-link -shared -o bin\glew-sharedd.dll  -Xlinke
r /MANIFEST:EMBED -Xlinker /implib:lib\glew-sharedd.lib -Xlinker /pdb:bin\glew-sharedd.pdb -Xlinker /version:2.2 CMakeFi
les/libglew_shared.dir/src/glew.c.obj  -lopengl32.lib  -lkernel32 -luser32 -lgdi32 -lwinspool -lshell32 -lole32 -loleaut
32 -luuid -lcomdlg32 -ladvapi32 -loldnames  && cd ."

There is only one difference with your link command. It is --dependent-lib=msvcrtd. But, I removed it from the generated build script and tried to build, the build failed with an unrelated error.

LINK : fatal error LNK1158: cannot run 'rc.exe'

clang: error: linker command failed with exit code 1158 (use -v to see invocation)

If you are still trying this, Can you share your build environment?