mono / CppSharp

Tools and libraries to glue C/C++ APIs to high-level languages
MIT License
3.1k stars 509 forks source link

Error fatal: 'string' file not found #830

Open dmitrydvm opened 7 years ago

dmitrydvm commented 7 years ago

Hi, I have this error. How can I fix it? C++# from Nuget.

Parsing libraries...
Parsed 'ive.lib'
Parsing code...
Error parsing 'ive.h'
C:\dst\include\ive.h(4,10): fatal: 'string' file not found

OS: W10 AU x64, VS2015up3

Used headers
#ifndef IVE_H
#define IVE_H

#include <string>     <--this is line 4
#include <functional>
#include <map>
#include <unordered_map>

namespace ive {

using namespace std;
...
Used settings
            var options = driver.Options;
            options.GeneratorKind = GeneratorKind.CSharp;
            var module = options.AddModule("dst");
            module.IncludeDirs.Add("C:\\dst\\include");
            module.Headers.Add("ive.h");
            module.LibraryDirs.Add("C:\\dst\\lib");
            module.Libraries.Add("ive.lib");

Target: MSVC/GCC/Clang

Other settings

Stack trace or incompilable generated code
ddobrev commented 7 years ago

We were able to solve a similar problem with the Android NDK today. Could you please specify what system headers you use?

dmitrydvm commented 7 years ago

@ddobrev Only these. You say about them?

#include <string>
#include <functional>
#include <map>
#include <unordered_map>
ddobrev commented 7 years ago

@boodoolak I am sorry, I wasn't exact in my question. What I meant was: what environment provides your system headers? Is it MSVC, MinGW, Android NDK, sth else?

dmitrydvm commented 7 years ago

@ddobrev MSVS. The problem was solved just now after installing VS2017 and all components for c++. I'm sorry.

But now there is another problem:

Error parsing 'hhive.h'
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.10.25017\include\xstring(1905,26): error: constexpr variable '_Memcpy_move_offset' must be initialized by a constant expression

Unfortunately I don't know c++. What does this error mean? How can I fix it?

tritao commented 7 years ago

It's probably related due to us using an "outdated" Clang revision that does not play nice with some of VS2017 headers. Using VS2015 or older for parsing is probably the most compatible right now.

tritao commented 7 years ago

By the way the initial issue could be caused by not setting up MSVC headers.

See SetupMSVC method in https://github.com/mono/CppSharp/blob/a954c54a6cd2f84dedf987c2812f48ca2a8e8ee1/src/Parser/ParserOptions.cs#L17 .

dmitrydvm commented 7 years ago

After installing vs2017 old vs2015 began using the path from vs2017 (C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC...). I'll try to remove vs2017 and then reinstall vs2015. Most likely the problem is in the installation vs2015.

dmitrydvm commented 7 years ago

Yes, removing vs2017 is helped, Library was generated successfully. That means this string? The query API is not registered. Assuming no instances are installed. image

ddobrev commented 7 years ago

Yes, this output means success. If you use the option for automatic compilation, your binding will also be compiled for you.

dmitrydvm commented 7 years ago

@ddobrev @tritao Thank you!

dmitrydvm commented 7 years ago

I added options.CompileCode = true; but compile failed Compiling HiveLibrary... C:\dst\Output\HiveLibrary.cs(243,33) : error CS0234: The type or namespace name 'BasicString' does not exist in the namespace 'Std' (are you missing an assembly reference?)