c3lang / c3c

Compiler for the C3 language
GNU Lesser General Public License v3.0
2.53k stars 147 forks source link

raylib examples failed to compile #1123

Closed LukyGuyLucky closed 6 months ago

LukyGuyLucky commented 6 months ago

1 , downloaded raylib.c3i,raylib.lib from c3lang/vendor;

  1. in c3\resources\examples\raylib folder,downloaded raylib.c3l by executing c3c vendor-fetch raylib;
  2. E:\Learning\c3pack\c3c-master\resources\examples\raylib>c3c compile raylib_arkanoid.c3 raylib.c3i -l raylib.lib lld-link: error: duplicate symbol: __report_gsfailure

    defined at D:\a_work\1\s\src\vctools\crt\vcstartup\src\gs\gs_report.c:217 msvcrt.lib(gs_report.obj) defined at VCRUNTIME140.dll Failed to create an executable: (null)

【Acutally my pc has no D drive,don't know what D:\a_work...stuff means... 】 Win10 64 bit +VS community 2019+the lasted released c3.

(BTW: what is the *.c3l file about?I learnt from the forum but I have no clue what it is and what it is for.)

lerno commented 6 months ago

Try to excluding bundling the stdlib for windows: --wincrt=none. In this case I believe libc is included in raylib and then included again by default. That should be fixed and is a bug in vendor.

LukyGuyLucky commented 6 months ago

Try to excluding bundling the stdlib for windows: --wincrt=none. In this case I believe libc is included in raylib and then included again by default. That should be fixed and is a bug in vendor.

Thanks for the prompt feedback. Sorry still can't make it ----

E:\Learning\c3pack\c3c-master\resources\examples\raylib>c3c compile raylib_arkanoid.c 3 raylib.c3i raylib.lib --wincrt=none
File names must be a non-empty name followed by .c3 or they cannot be compiled: 'rayl ib.lib' is invalid.

E:\Learning\c3pack\c3c-master\resources\examples\raylib>c3c compile raylib_arkanoid.c 3 raylib.c3i -l raylib.lib --wincrt=none
lld-link: error: undefined symbol: timeBeginPeriod

referenced by raylib.lib(rcore.obj):($LN78)

lld-link: error: undefined symbol: timeEndPeriod

referenced by raylib.lib(rcore.obj):($LN23)

lld-link: error: undefined symbol: __declspec(dllimport) ChoosePixelFormat

referenced by raylib.lib(rglfw.obj):($LN29)

lld-link: error: undefined symbol: __declspec(dllimport) CreateBitmap

referenced by raylib.lib(rglfw.obj):(createIcon)

lld-link: error: undefined symbol: __declspec(dllimport) CreateDCW

referenced by raylib.lib(rglfw.obj):($LN30)
referenced by raylib.lib(rglfw.obj):($LN8)
referenced by raylib.lib(rglfw.obj):(createMonitor)

lld-link: error: undefined symbol: __declspec(dllimport) CreateRectRgn

referenced by raylib.lib(rglfw.obj):(updateFramebufferTransparency)

lld-link: error: undefined symbol: __declspec(dllimport) DeleteDC

referenced by raylib.lib(rglfw.obj):($LN30)
referenced by raylib.lib(rglfw.obj):($LN8)
referenced by raylib.lib(rglfw.obj):(createMonitor)

lld-link: error: undefined symbol: __declspec(dllimport) DeleteObject

referenced by raylib.lib(rglfw.obj):(createIcon)
referenced by raylib.lib(rglfw.obj):(createIcon)
referenced by raylib.lib(rglfw.obj):(createIcon)
referenced 1 more times

lld-link: error: undefined symbol: __declspec(dllimport) DescribePixelFormat

referenced by raylib.lib(rglfw.obj):($LN62)
referenced by raylib.lib(rglfw.obj):(choosePixelFormatWGL)
referenced by raylib.lib(rglfw.obj):(choosePixelFormatWGL)

lld-link: error: undefined symbol: __declspec(dllimport) GetDeviceCaps

referenced by raylib.lib(rglfw.obj):($LN11)
referenced by raylib.lib(rglfw.obj):($LN11)
referenced by raylib.lib(rglfw.obj):($LN13)
referenced 9 more times

lld-link: error: undefined symbol: __declspec(dllimport) SetPixelFormat

referenced by raylib.lib(rglfw.obj):($LN29)
referenced by raylib.lib(rglfw.obj):($LN62)

lld-link: error: undefined symbol: __declspec(dllimport) CreateDIBSection

referenced by raylib.lib(rglfw.obj):(createIcon)

lld-link: error: undefined symbol: __declspec(dllimport) GetDeviceGammaRamp

referenced by raylib.lib(rglfw.obj):($LN30)

lld-link: error: undefined symbol: __declspec(dllimport) SetDeviceGammaRamp

referenced by raylib.lib(rglfw.obj):($LN8)

lld-link: error: undefined symbol: __declspec(dllimport) SwapBuffers

referenced by raylib.lib(rglfw.obj):(swapBuffersWGL)

lld-link: error: undefined symbol: __declspec(dllimport) TrackMouseEvent

referenced by raylib.lib(rglfw.obj):($LN108)

lld-link: error: undefined symbol: __declspec(dllimport) TranslateMessage

referenced by raylib.lib(rglfw.obj):($LN24)
referenced by raylib.lib(rglfw.obj):($LN52)

lld-link: error: undefined symbol: __declspec(dllimport) DispatchMessageW

referenced by raylib.lib(rglfw.obj):($LN24)
referenced by raylib.lib(rglfw.obj):($LN52)

lld-link: error: undefined symbol: __declspec(dllimport) PeekMessageW

referenced by raylib.lib(rglfw.obj):($LN24)
referenced by raylib.lib(rglfw.obj):($LN24)
referenced by raylib.lib(rglfw.obj):($LN52)
referenced 2 more times

lld-link: error: undefined symbol: __declspec(dllimport) GetMessageTime

referenced by raylib.lib(rglfw.obj):($LN59)

lld-link: error: too many errors emitted, stopping now (use /errorlimit:0 to see all errors)
Failed to create an executable: (null)

lerno commented 6 months ago

c3c compile raylib_arkanoid.c 3 --lib raylib.c3l --wincrt=none is what you want.

lerno commented 6 months ago

What you were doing was to manually link, and for that you'd have to link with additional libraries. Using .c3l files, all those additional link arguments are already included.

LukyGuyLucky commented 6 months ago

c3c compile raylib_arkanoid.c 3 --lib raylib.c3l --wincrt=none is what you want.

Acturally I have tried this before reporting.It doesn't work--- E:\Learning\c3pack\c3c-master\resources\examples\raylib>c3c compile raylib_arkanoid.c3 --lib raylib.c3l --wincrt=none Invalid library name 'raylib.c3l', it should be something like 'foo_lib'.

if I change raylib.c3l to raylib,it will complain--

raylib>Required library 'raylib' could not be found.

I knew I was missing something,but just can't figure it out.

lerno commented 6 months ago

Yes, you're right, it should be --lib raylib but you have to specify where raylib.c3l can be found as well: --lib raylib --libdir .

But I think this isn't really good, I'm raising an issue to improve it so that --libdir is . by default.

LukyGuyLucky commented 6 months ago

Yes, you're right, it should be --lib raylib but you have to specify where raylib.c3l can be found as well: --lib raylib --libdir .

But I think this isn't really good, I'm raising an issue to improve it so that --libdir is . by default.

Great! All three examples work great! (for snake game,there are a couple of explicit cast requirements by the compiler which can be fixed very easily.

The compiling is very very fast!Hope it is kinda stable in windows,I love c3 for all the design philosophy and considerations(I read almost all the posts in handmade.network).

BTW,I have left message in the forum subjected to "some comparisons, confusions, & praisals“,I am expecting to hear from you.

Thank you and best regards

lerno commented 6 months ago

Thank you, I updated the snake example as well, and improved the errors for --lib and added '.' as the default if no libdir was specified.