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

Head scratcher - where's the .lib? #4

Open
dlaio opened this issue Dec 4, 2015 · 2 comments
Open

Head scratcher - where's the .lib? #4

dlaio opened this issue Dec 4, 2015 · 2 comments

Comments

@dlaio
Copy link

dlaio commented Dec 4, 2015

The windows build doesnt end up outputting a .lib file in the /build/binaries/helloSharedLibrary/ directory, so the executable isnt able to link to it (therefore fails).

The library is in the static folder, copying it to the shared directory will make it work, but I dont think that is the intent. Oddly, the samples in the gradle release produce a .lib file in the shared folder, and as far as I can tell, the gradle.build file is the same.

Any ideas what is going on? Why isnt there a .lib file in the shared folder for this project? Just trying to wrap my head around what the gradle native plugin is doing. My first thought is that the link step should actually be looking for the .lib in the "static" folder, not the shared folder, but I dont know enough about the domain to know if this is a bug.

@Araeos
Copy link

Araeos commented Apr 10, 2016

During linking with Visual Studio, if there is no symbol to be exported, then the .lib file will not be created.
Append the following in build.gradle:

model {
    binaries {
        withType(SharedLibraryBinarySpec) {
            if (toolChain in VisualCpp) {
                cppCompiler.define "DLL_EXPORT"
            }
        }
    }
}

And change at least the interface of the class Hello to:

#if defined(_WIN32) && defined(DLL_EXPORT)
#define LIB_FUNC __declspec(dllexport)
#else
#define LIB_FUNC
#endif

class Hello 
{
    private:
        const char * who;

    public:
        LIB_FUNC Hello(const char * who);

        void LIB_FUNC sayHello(unsigned n = 1);

};

@carlosvin
Copy link
Owner

@Araeos thanks for the reply, I can't test it.

@dlaio , can you please test the solution proposed by @Araeos? If it is OK, can you please close the issue?

This was referenced May 16, 2016
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

No branches or pull requests

3 participants