tchar.h not found on cygwin
Asked Answered
H

2

5

I'm running the latest cygwin on windows 7 (32-bit), and trying to build an open-source project, RtAudio (it doesn't currently build on this platform).

One of the problems I've worked around is an error on the line #include <tchar.h>.

My build line is:

g++ -O2 -Wall -Iinclude -DHAVE_GETTIMEOFDAY -D__WINDOWS_DS__ -c RtAudio.cpp -o RtAudio.o

The error is:

tchar.h: No such file or directory

If I add /usr/include/mingw (which contains tchar.h) to the list of include paths, I get a lot more errors.

I've worked around the problem by not using LPCTSTR, and just overloading the one function that requires it for const char* and const wchar_t* so I could avoid including tchar.h, but is there a better way to do this?

Historicity answered 12/11, 2010 at 20:23 Comment(2)
Why are you using Cygwin? RtAudio claims to have native Windows support; you'd be better off using MinGW directly, or a Microsoft compiler. It looks like the RtAudio distribution includes a Visual Studio setup that may be informative.Bouzoun
@Porculus, good question. Other components that I'm using require a linuxy environment.Historicity
S
5

tchar.h is a Windows header. The software will have to be ported to libiconv or ICU if it needs more than just the basics.

Stairway answered 12/11, 2010 at 20:27 Comment(6)
so it sounds like the overload is the way to go in this situation?Historicity
I can't really say without knowing exactly what you did.Stairway
tchar.h cannot be foundZuckerman
are you saying that gcc does not have tchar.h ?Zuckerman
@MistyD: GCC will never have tchar.h.Stairway
thanks that worked, for followers, for me seemed to be #include "w32api/windows.h" (in cygwin) or you can include the tchar.h file directlyVav
A
2

If you want to build this for Cygwin, you should ensure that it uses the Unix/Linux code paths rather than the Windows ones. In particular, the WIN32 macro is often used to guard Windows code, but that's defined on Cygwin too, so you might have to change any such guards to #if defined(__WIN32__) && !defined(__CYGWIN__).

The other way of course is to build this for native Windows. Within Cygwin, you can do this using gcc-3 -mno-cygwin or the MinGW-w64 cross compiler that was recently added to the Cygwin distro.

Averi answered 13/11, 2010 at 8:43 Comment(1)
could you explain what you mean by #if defined(__WIN32__) && !defined(__CYGWIN__). where should i add that header ?Zuckerman

© 2022 - 2024 — McMap. All rights reserved.