Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TCC Support #1158

Open
AlbertShown opened this issue May 3, 2023 · 4 comments
Open

TCC Support #1158

AlbertShown opened this issue May 3, 2023 · 4 comments

Comments

@AlbertShown
Copy link

AlbertShown commented May 3, 2023

When you build using TCC, we got these errors:

tcc: error: undefined symbol 'opendir'
tcc: error: undefined symbol 'closedir'
tcc: error: undefined symbol 'IsWow64Process'
@AlbertShown
Copy link
Author

AlbertShown commented May 3, 2023

https://github.com/TinyCC/tinycc

I'm trying to create a DLL:

tcc -g -fPIC -m64 -o civetweb.o -c civetweb.c -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET
tcc -g -fPIC -m64 -o MyLib.o -c MyLib.c
tcc -g -shared -o MyLib.dll MyLib.o civetweb.o -lws2_32 -lAdvapi32

Compile fine. But linking got this:

tcc: error: undefined symbol 'opendir'
tcc: error: undefined symbol 'closedir'
tcc: error: undefined symbol 'IsWow64Process'

@bel2125
Copy link
Member

bel2125 commented May 6, 2023

I have never tested TCC.
It seems it misses some libraries and you are using some defines that do not seem to be consistent.

opendir/closedir are POSIX functions to iterate a directory listing. It seems you are missing them. IsWow64Process is a Windows function.
Probably the system does not know if you are building for Windows or Linux because TCC uses some #define that are not known / not checked in the civetweb source code.

I guess this is not a big deal to fix, but I never tested TCC.

@AlbertShown
Copy link
Author

Thank you for your comment. This is still related to Civetweb probably because it works fine with GCC on Windows.

gcc -Os -fPIC -m64 -o civetweb.o -c civetweb.c -DNDEBUG -DNO_CACHING -DNO_CGI -DNO_SSL -DUSE_WEBSOCKET -DMUST_IMPLEMENT_CLOCK_GETTIME
gcc -O3 -fPIC -m64 -o MyLib.o -c MyLib.c
gcc -shared -o MyLib.dll MyLib.o civetweb.o -lws2_32

@bel2125
Copy link
Member

bel2125 commented May 14, 2023

Since I have no experience using TCC, I am not sure what needs to be fixed where.
In the linked issue there is something written about adding tlhelp32.h to the SDK.

opendir/closedir/readdir should not be used by the code for Windows if you set your defines correctly:

#ifdef _WIN32
  ... opendir is not used here ---
#else
  d->dir = opendir(path);
  ...
#endif

If you are building for Windows, _WIN32 must be set and you will not require opendir.
If you are building for Linux on Windows: I know CivetWeb works well when using WSL to build.

I do not know TCC or your particular use case, so I think I cannot help more than hinting that something seems to be inconsistent in the build environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants