How to use libclang with STL?
I'm trying to parse a library using libclang, and I'm stuck with what could be a very simple issue: how to configure it with STL?
At the moment, it fails to parse a translation unit because it can't find <string>
.
Here's what I tried :
char *args = {"-x", "c++", "-Ic:/my/library/includes", "-IG:/Prog/libcxx-3.4/include"};
clang_parseTranslationUnit(index, "c:/my/library/test.cpp", args, 4, 0, 0, 0);
I'm on windows, with the precompiled clang binaries downloaded from llvm.org, and I tried with various STL implementations :
- Visual studio
- MingW
- libCXX
In each case, I ended up with unknown types.
For example, with mingw, I've got the following error messages :
/mingw/includewchar.h:221:71: error: unknown type name '_locale_t'
/mingw/includewchar.h:223:81: error: unknown type name '_locale_t'
/mingw/includestdlib.h:173:65: error: unknown type name '_locale_t'
/mingw/includestdlib.h:175:75: error: unknown type name '_locale_t'
/mingw/includeio.h:301:14: error: unknown type name 'off64_t'
/mingw/includeio.h:301:36: error: C++ requires a type specifier for all declarations
/mingw/includeio.h:302:14: error: unknown type name 'off64_t'
/mingw/includeio.h:302:39: error: unknown type name 'off64_t'
/mingw/includeunistd.h:65:20: error: unknown type name 'off_t'
The rare tutorials I've found about this subject don't talk about this subject...
c++ windows stl mingw libclang
add a comment |
I'm trying to parse a library using libclang, and I'm stuck with what could be a very simple issue: how to configure it with STL?
At the moment, it fails to parse a translation unit because it can't find <string>
.
Here's what I tried :
char *args = {"-x", "c++", "-Ic:/my/library/includes", "-IG:/Prog/libcxx-3.4/include"};
clang_parseTranslationUnit(index, "c:/my/library/test.cpp", args, 4, 0, 0, 0);
I'm on windows, with the precompiled clang binaries downloaded from llvm.org, and I tried with various STL implementations :
- Visual studio
- MingW
- libCXX
In each case, I ended up with unknown types.
For example, with mingw, I've got the following error messages :
/mingw/includewchar.h:221:71: error: unknown type name '_locale_t'
/mingw/includewchar.h:223:81: error: unknown type name '_locale_t'
/mingw/includestdlib.h:173:65: error: unknown type name '_locale_t'
/mingw/includestdlib.h:175:75: error: unknown type name '_locale_t'
/mingw/includeio.h:301:14: error: unknown type name 'off64_t'
/mingw/includeio.h:301:36: error: C++ requires a type specifier for all declarations
/mingw/includeio.h:302:14: error: unknown type name 'off64_t'
/mingw/includeio.h:302:39: error: unknown type name 'off64_t'
/mingw/includeunistd.h:65:20: error: unknown type name 'off_t'
The rare tutorials I've found about this subject don't talk about this subject...
c++ windows stl mingw libclang
add a comment |
I'm trying to parse a library using libclang, and I'm stuck with what could be a very simple issue: how to configure it with STL?
At the moment, it fails to parse a translation unit because it can't find <string>
.
Here's what I tried :
char *args = {"-x", "c++", "-Ic:/my/library/includes", "-IG:/Prog/libcxx-3.4/include"};
clang_parseTranslationUnit(index, "c:/my/library/test.cpp", args, 4, 0, 0, 0);
I'm on windows, with the precompiled clang binaries downloaded from llvm.org, and I tried with various STL implementations :
- Visual studio
- MingW
- libCXX
In each case, I ended up with unknown types.
For example, with mingw, I've got the following error messages :
/mingw/includewchar.h:221:71: error: unknown type name '_locale_t'
/mingw/includewchar.h:223:81: error: unknown type name '_locale_t'
/mingw/includestdlib.h:173:65: error: unknown type name '_locale_t'
/mingw/includestdlib.h:175:75: error: unknown type name '_locale_t'
/mingw/includeio.h:301:14: error: unknown type name 'off64_t'
/mingw/includeio.h:301:36: error: C++ requires a type specifier for all declarations
/mingw/includeio.h:302:14: error: unknown type name 'off64_t'
/mingw/includeio.h:302:39: error: unknown type name 'off64_t'
/mingw/includeunistd.h:65:20: error: unknown type name 'off_t'
The rare tutorials I've found about this subject don't talk about this subject...
c++ windows stl mingw libclang
I'm trying to parse a library using libclang, and I'm stuck with what could be a very simple issue: how to configure it with STL?
At the moment, it fails to parse a translation unit because it can't find <string>
.
Here's what I tried :
char *args = {"-x", "c++", "-Ic:/my/library/includes", "-IG:/Prog/libcxx-3.4/include"};
clang_parseTranslationUnit(index, "c:/my/library/test.cpp", args, 4, 0, 0, 0);
I'm on windows, with the precompiled clang binaries downloaded from llvm.org, and I tried with various STL implementations :
- Visual studio
- MingW
- libCXX
In each case, I ended up with unknown types.
For example, with mingw, I've got the following error messages :
/mingw/includewchar.h:221:71: error: unknown type name '_locale_t'
/mingw/includewchar.h:223:81: error: unknown type name '_locale_t'
/mingw/includestdlib.h:173:65: error: unknown type name '_locale_t'
/mingw/includestdlib.h:175:75: error: unknown type name '_locale_t'
/mingw/includeio.h:301:14: error: unknown type name 'off64_t'
/mingw/includeio.h:301:36: error: C++ requires a type specifier for all declarations
/mingw/includeio.h:302:14: error: unknown type name 'off64_t'
/mingw/includeio.h:302:39: error: unknown type name 'off64_t'
/mingw/includeunistd.h:65:20: error: unknown type name 'off_t'
The rare tutorials I've found about this subject don't talk about this subject...
c++ windows stl mingw libclang
c++ windows stl mingw libclang
edited Nov 22 '18 at 8:01
Krantz
1849
1849
asked Mar 18 '14 at 13:15
MikarnageMikarnage
595422
595422
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
Since libclang was precompiled, it doesn't know about the exact paths of the standard libraries used by your compilers. You'll have to tell it about the standard include path using -I
switches in your arguments list, when calling clang_parseTranslationUnit
.
Here is the command I use to find about the inclusion paths for gcc
on Linux. You should be able to adapt it to MinGW in your windows environment:
$ echo "" | g++ -v -x c++ -E -
...
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/4.8
/usr/include/x86_64-linux-gnu/c++/4.8
/usr/include/c++/4.8/backward
/usr/lib/gcc/x86_64-linux-gnu/4.8/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
...
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22480534%2fhow-to-use-libclang-with-stl%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
Since libclang was precompiled, it doesn't know about the exact paths of the standard libraries used by your compilers. You'll have to tell it about the standard include path using -I
switches in your arguments list, when calling clang_parseTranslationUnit
.
Here is the command I use to find about the inclusion paths for gcc
on Linux. You should be able to adapt it to MinGW in your windows environment:
$ echo "" | g++ -v -x c++ -E -
...
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/4.8
/usr/include/x86_64-linux-gnu/c++/4.8
/usr/include/c++/4.8/backward
/usr/lib/gcc/x86_64-linux-gnu/4.8/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
...
add a comment |
Since libclang was precompiled, it doesn't know about the exact paths of the standard libraries used by your compilers. You'll have to tell it about the standard include path using -I
switches in your arguments list, when calling clang_parseTranslationUnit
.
Here is the command I use to find about the inclusion paths for gcc
on Linux. You should be able to adapt it to MinGW in your windows environment:
$ echo "" | g++ -v -x c++ -E -
...
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/4.8
/usr/include/x86_64-linux-gnu/c++/4.8
/usr/include/c++/4.8/backward
/usr/lib/gcc/x86_64-linux-gnu/4.8/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
...
add a comment |
Since libclang was precompiled, it doesn't know about the exact paths of the standard libraries used by your compilers. You'll have to tell it about the standard include path using -I
switches in your arguments list, when calling clang_parseTranslationUnit
.
Here is the command I use to find about the inclusion paths for gcc
on Linux. You should be able to adapt it to MinGW in your windows environment:
$ echo "" | g++ -v -x c++ -E -
...
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/4.8
/usr/include/x86_64-linux-gnu/c++/4.8
/usr/include/c++/4.8/backward
/usr/lib/gcc/x86_64-linux-gnu/4.8/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
...
Since libclang was precompiled, it doesn't know about the exact paths of the standard libraries used by your compilers. You'll have to tell it about the standard include path using -I
switches in your arguments list, when calling clang_parseTranslationUnit
.
Here is the command I use to find about the inclusion paths for gcc
on Linux. You should be able to adapt it to MinGW in your windows environment:
$ echo "" | g++ -v -x c++ -E -
...
#include "..." search starts here:
#include <...> search starts here:
/usr/include/c++/4.8
/usr/include/x86_64-linux-gnu/c++/4.8
/usr/include/c++/4.8/backward
/usr/lib/gcc/x86_64-linux-gnu/4.8/include
/usr/local/include
/usr/lib/gcc/x86_64-linux-gnu/4.8/include-fixed
/usr/include/x86_64-linux-gnu
/usr/include
End of search list.
...
answered Mar 20 '14 at 14:29
FrancescoFrancesco
9,01222850
9,01222850
add a comment |
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22480534%2fhow-to-use-libclang-with-stl%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown