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

Fails build with 'printf' was not declared in this scope #65

Closed
joa-quim opened this issue Mar 1, 2014 · 10 comments
Closed

Fails build with 'printf' was not declared in this scope #65

joa-quim opened this issue Mar 1, 2014 · 10 comments

Comments

@joa-quim
Copy link

joa-quim commented Mar 1, 2014

Updated after my comment in #5982 but still get

julia> Pkg.build("Clang")
INFO: Building Clang
g++ wrapclang.cpp -fPIC -c -o wrapclang.cpp.o -I/c/programs/julia64/deps/llvm-3.3/include -g -Wall -
Wno-strict-aliasing -fno-omit-frame-pointer -fPIC -IC:/programs/llvm_trunk/compileds/include
wrapclang.cpp:1:0: warning: -fPIC ignored for target (all code is position independent) [enabled by
default]
wrapclang.cpp: In function 'void wci_debug_token(CXTranslationUnit, char*)':
wrapclang.cpp:118:69: error: 'printf' was not declared in this scope
wrapclang.cpp: In function 'void wci_print_tokens(CXTranslationUnit, char*)':
wrapclang.cpp:131:71: error: 'printf' was not declared in this scope
make: *** [wrapclang.cpp.o] Error 1
@joa-quim
Copy link
Author

joa-quim commented Mar 1, 2014

Sorry, I had forgotten to revert the makefile mods to try to build with a MSVC llvm build. Reverting those, I get again the missing headers error. Though I understand what this means I don't know what else I have to install

julia> Pkg.build("Clang")
INFO: Building Clang
g++ wrapclang.cpp -fPIC -c -o wrapclang.cpp.o -I/c/programs/julia64/deps/llvm-3.3/include -g -Wall -
Wno-strict-aliasing -fno-omit-frame-pointer -fPIC
wrapclang.cpp:1:0: warning: -fPIC ignored for target (all code is position independent) [enabled by
default]
wrapclang.cpp:6:27: fatal error: clang-c/Index.h: No such file or directory
compilation terminated.
make: *** [wrapclang.cpp.o] Error 1

@ihnorton
Copy link
Collaborator

ihnorton commented Mar 1, 2014

Could you try building Clang within the Julia LLVM (add BUILD_LLVM_CLANG = 1 to julia/Make.user). That is probably the easiest way to get this working.

@joa-quim
Copy link
Author

joa-quim commented Mar 1, 2014

Thanks, I'll try it tomorrow.

@joa-quim
Copy link
Author

joa-quim commented Mar 1, 2014

OK, resuming ...

I did update the makefile to point to where Index.h lives

INC += -I"$(JULIA_ROOT)/deps/llvm-$(LLVM_VER)/tools/clang/include"

but most oddly a part of that declaration is trimmed (see the include path below) and it still fails complaining of Index.h

julia> Pkg.build("Clang")
INFO: Building Clang
g++ wrapclang.cpp -fPIC -c -o wrapclang.cpp.o -I/c/programs/julia64/deps/llvm-3.3/include -g -Wall -Wno-strict-aliasing -fno-omit-frame-pointer -fPIC
wrapclang.cpp:1:0: warning: -fPIC ignored for target (all code is position independent) [enabled by default]
wrapclang.cpp:6:27: fatal error: clang-c/Index.h: No such file or directory

I solved this by inserting the include path directly in the FLAGS variable, but now it errors because

g++ wrapclang.cpp -fPIC -c -o wrapclang.cpp.o -I/c/programs/julia64/deps/llvm-3.3/include -g -Wall -Wno-strict-aliasing -fno-omit-frame-pointer -fPIC  -I/c/programs/julia64/deps/llvm-3.3/tools/clang/include
wrapclang.cpp:1:0: warning: -fPIC ignored for target (all code is position independent) [enabled by default]
g++ wrapclang.cpp.o -rdynamic -shared -o libwrapclang.dll -L/c/programs/julia64/deps/llvm-3.3/build_Release/Release/lib   -lclang
g++.exe: error: unrecognized command line option '-rdynamic'

removing the -rdynamic only triggers a bunch of other errors

g++ wrapclang.cpp.o -shared -o libwrapclang.dll -L/c/programs/julia64/deps/llvm-3.3/build_Release/Release/lib   -lclang
wrapclang.cpp.o: In function `wci_getFileName':
C:\j\.julia\v0.3\Clang\deps\src/wrapclang.h:2: undefined reference to `clang_getFileName'
wrapclang.cpp.o: In function `wci_getNullLocation':
C:\j\.julia\v0.3\Clang\deps\src/wrapclang.h:6: undefined reference to `clang_getNullLocation'
wrapclang.cpp.o: In function `wci_equalLocations':
...

@ihnorton
Copy link
Collaborator

ihnorton commented Mar 1, 2014

Ah, I guess again with the stricter g++ (rdynamic is unused on Windows and used to be ignored). We should check and disable on Windows.

undefined reference to clang_getFileName' wrapclang.cpp.o: In functionwci_getNullLocation':

Is there a libclang.dll in /c/programs/julia64/deps/llvm-3.3/build_Release/Release/li?

@joa-quim
Copy link
Author

joa-quim commented Mar 1, 2014

No, there isn't and I actually tried to force the link against the clang.dll but got a strange declaration that:

c:/programs/julia64/deps/llvm-3.3/build_Release/Release/bin//clang.dll: file not recognized: File format not recognized

As far as I understand it, the problem is that the missing symbols are inside clang.a but somehow are not being exported. That was why I tried to link via the DLL but failed with the above error.

@ihnorton
Copy link
Collaborator

ihnorton commented Mar 1, 2014

There should be a libclang.dll somewhere... that is the one you need to link against. clang.a is just the object file, not the shared library, and clang.dll is the full Clang (I think..) not the C-exported interface which is used here.

@joa-quim
Copy link
Author

joa-quim commented Mar 1, 2014

Well, I have one libclang.dll but in my MSVC build. Inside the julia64 dir, where all msys build stuff resides, there is none. But I found one libclang.def

@ihnorton
Copy link
Collaborator

ihnorton commented Mar 1, 2014

Well something is wrong with the Clang build, then. I will try to build it myself and see if/where it should be.

@vtjnash
Copy link
Collaborator

vtjnash commented Mar 13, 2014

Not sure if this is relevant, but on mingw, we can't build the LLVM shared libraries because their linker rules are wrong.

@Gnimuc Gnimuc closed this as completed Dec 23, 2018
melonedo pushed a commit to melonedo/Clang.jl that referenced this issue Jul 20, 2021
Update to LibCURLBuilder v0.5.1 (FreeBSD support)
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

Successfully merging a pull request may close this issue.

4 participants