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

[cpp] #include <hx/HxcppMain.h #4199

Closed
adamretter opened this Issue May 10, 2015 · 4 comments

Comments

Projects
None yet
3 participants
@adamretter

adamretter commented May 10, 2015

I am trying to create a cross-platform API and library, and therefore I do not require my library to be executable, i.e. no main. Compilation of this library to Java works, I use the command line:

$ haxe -cp src -java java_out example.expath.file.FileModule

I also want to produce a compilation to C++, using the equivalent command line for the cpp backend:

$ haxe -cp src -cpp cpp_out example.expath.file.FileModule

I get the following compilation error:

g++ -Iinclude -DHX_DECLARE_MAIN -c -fvisibility=hidden -stdlib=libstdc++ -O2 -I/usr/lib/haxelib/hxcpp/3,2,81/include -DHX_MACOS -m64 -Wno-parentheses -Wno-unused-value -Wno-format-extra-args -DHXCPP_M64 -DHXCPP_VISIT_ALLOCS -DHXCPP_API_LEVEL=321 -x c++ -frtti -Wno-invalid-offsetof ./src/__main__.cpp -oobj/darwin64/501f6158___main__.o
Error: ./src/__main__.cpp:10:25: error: expected "FILENAME" or <FILENAME>
#include <hx/HxcppMain.h
                        ^
1 error generated.
Error: Build failed

Is it possible to generate a dynamically linked library using the CPP backend? I rather expected this to be the default if I did not pass -main to the haxe compiler command.

@Simn Simn modified the milestone: 3.3 May 11, 2015

@Simn Simn added the platform-cpp label May 11, 2015

@hughsando

This comment has been minimized.

Show comment
Hide comment
@hughsando

hughsando May 11, 2015

Member

The issue with the include has been fixed.
Usually, I would think the best way to make a dll would be to make a .lib file first, and then link this against a small, well-defined API, since a full export of all the haxe symbols would at least require the user of this dll to include a synchnonised version of hxcpp. The android target creates a dll with just one symbol exported - something like this may be possible, but maybe not useful.
You can generate a .lib file with the "-D static_link" define, whether or not you have "-main" specified.
As to whether no main should imply "-D static_link" or some kind of dll_link, is something I will think about.

Member

hughsando commented May 11, 2015

The issue with the include has been fixed.
Usually, I would think the best way to make a dll would be to make a .lib file first, and then link this against a small, well-defined API, since a full export of all the haxe symbols would at least require the user of this dll to include a synchnonised version of hxcpp. The android target creates a dll with just one symbol exported - something like this may be possible, but maybe not useful.
You can generate a .lib file with the "-D static_link" define, whether or not you have "-main" specified.
As to whether no main should imply "-D static_link" or some kind of dll_link, is something I will think about.

@hughsando hughsando closed this May 11, 2015

@adamretter

This comment has been minimized.

Show comment
Hide comment
@adamretter

adamretter May 11, 2015

@hughsando How do I get access to the fix?

I am not a C++ developer in any sense, but I am trying to create a small module that can be used from either Java or C++. I do not really also want to maintain anything additional outside of Haxe, i.e. another well-defined-API. Is it not possible to create a dynamic library + include files that I can distribute to C++ developers in Haxe?

adamretter commented May 11, 2015

@hughsando How do I get access to the fix?

I am not a C++ developer in any sense, but I am trying to create a small module that can be used from either Java or C++. I do not really also want to maintain anything additional outside of Haxe, i.e. another well-defined-API. Is it not possible to create a dynamic library + include files that I can distribute to C++ developers in Haxe?

@Simn

This comment has been minimized.

Show comment
Hide comment
@Simn

Simn May 11, 2015

Member

Check out builds.haxe.org for nightly builds.

Member

Simn commented May 11, 2015

Check out builds.haxe.org for nightly builds.

@adamretter

This comment has been minimized.

Show comment
Hide comment
@adamretter

adamretter May 11, 2015

@Simn Thanks. And how about my goal of generating a dynamic library and include files for C++ developers?

adamretter commented May 11, 2015

@Simn Thanks. And how about my goal of generating a dynamic library and include files for C++ developers?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment