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: error: undefined symbol 'round' #4465

Closed
shawnye opened this issue Jul 8, 2016 · 3 comments
Closed

tcc: error: undefined symbol 'round' #4465

shawnye opened this issue Jul 8, 2016 · 3 comments

Comments

@shawnye
Copy link

shawnye commented Jul 8, 2016

When importing strutils, error occurred when compiling DEBUG exe with tcc version 0.9.26

helloworld.nim

import strutils
echo "hello world ".split(" ")
E:\WORKSPACE\nim\create_fileordirs>nim --cc:tcc c   helloworld.nim
Hint: used config file 'D:\DEV\Nim-0.14.2\config\nim.cfg' [Conf]
Hint: system [Processing]
Hint: helloworld [Processing]
Hint: strutils [Processing]
Hint: parseutils [Processing]
Hint: math [Processing]
CC: helloworld
CC: stdlib_system
CC: stdlib_strutils
CC: stdlib_parseutils
CC: stdlib_math
Hint:  [Link]
tcc: error: undefined symbol 'round'
Error: execution of an external program failed: 'tcc.exe -o e:\workspace\nim\cre
ate_fileordirs\helloworld.exe      e:\workspace\nim\create_fileordirs\nimcache\s
tdlib_math.o e:\workspace\nim\create_fileordirs\nimcache\stdlib_parseutils.o e:\
workspace\nim\create_fileordirs\nimcache\stdlib_strutils.o e:\workspace\nim\crea
te_fileordirs\nimcache\stdlib_system.o e:\workspace\nim\create_fileordirs\nimcac
he\helloworld.o'

if using -d:release , then it is OK.

@mbaulch
Copy link
Contributor

mbaulch commented Jul 10, 2016

I believe this issue is Windows-specific.

TCC on Win32 provides `include/math.h' but no actual implementation. It needs the lib to be provided, and in a suitable format (see below).

(from tcc-0.9.26/win32/tcc-win32.txt)

On the object file level, currently TCC supports only the ELF format,
not COFF as used by MinGW and MSVC. It is not possible to exchange
object files or libraries between TCC and these compilers. However
libraries for TCC from objects by TCC can be made using tiny_libmaker
or MinGW's ar.

Not really an issue with the Nim compiler.

@shawnye
Copy link
Author

shawnye commented Jul 11, 2016

Thank you ,I see. It's so pity that can't not use tcc reliablely on Windows.

@shawnye shawnye closed this as completed Jul 11, 2016
@90999
Copy link

90999 commented Oct 29, 2024

https://lists.nongnu.org/archive/html/tinycc-devel/2017-03/msg00015.html

First, there's no "current development on github". The main tcc repo is the mob
branch available at this repo: http://repo.or.cz/w/tinycc.git . tcc repos/forks/mirrors
on github could be outdated (unless you know otherwise).

Second, 0.9.26 indeed had issues with the "t" constraint and math.h (taken from
mingw) dependency on it. The "t" constraint is still not supported with more recent
tcc, but the issues themselves should be mostly solved since tcc switched to a
different implementations (inlined from math.h).

Your options are one of:

  1. Build the latest mob branch which includes the fixes, and should just work.
  2. Replace your math.h with the one from latest git (at win32/include/math.h) and
    add "tcc" dir to your include dir and in it put tcc_libm.h (from the repo at
    win32/include/tcc/tcc_libm.h)
  3. For your convenience, I'm attaching those two files. Just extract it to your include
    folder and it should work (it will overwrite math.h and add tcc/tcc_libm.h).

On Wednesday, March 15, 2017 9:48 AM, Charles Lohr address@hidden wrote:

I've found only small bits and pieces of information about how to do this strewn across the internet. Hopefully this message will have enough keywords in it that others will find it... and hopefully someone on the list will be able to help.

I've tried pulling some files from the current development github, to no avail.

After downloading TinyCC 0.9.26, and compiling, I randomly get the following error:

c:/tcc/include/math.h:217: error: unknown constraint 't'
__asm__ ("fabs;" : "=t" (res) : "0" (x));

Whenever I try to use fabsf(...)

That aside, if I only make my program #include <math.h>

I will run into a slew of :

tcc: error: undefined symbol 'strtof'
tcc: error: undefined symbol 'sqrtf'
tcc: error: undefined symbol 'acosf'
tcc: error: undefined symbol 'cosf'
tcc: error: undefined symbol 'sinf'
tcc: error: undefined symbol 'atan2f'
tcc: error: undefined symbol 'asinf'
tcc: error: undefined symbol 'fabsf'

I can't seem to find any objects distributed with tcc that provide this functionality. What are we to do for the Windows port of tcc? No libm.dll, libm.a, libm.c, nothing?

What is the recommended compile line for something that uses these features?

Charles


Tinycc-devel mailing list
address@hidden
https://lists.nongnu.org/mailman/listinfo/tinycc-devel

file: https://lists.nongnu.org/archive/html/tinycc-devel/2017-03/zip7zu0wmdBBt.zip

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

3 participants