Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


TheComet

Member Since 02 Oct 2013
Offline Last Active Feb 26 2015 04:47 PM

Posts I've Made

In Topic: dllimport/dllexport with multiple depending shared libs

18 February 2015 - 04:12 PM

Does bar.DLL attempt to call any of the methods it's supposed to be importing from foo.DLL? The linker is pretty aggressive about making sure it doesn't import/export what it doesn't think it has to.

Yes, bar.DLL calls functions from foo.DLL.

 

I've created a small sample project, you can clone it here: https://github.com/TheComet93/dll-example.git

 

In the top level CMakeLists.txt is the following line:

add_definitions (-D_BUILDING)

This means that _BUILDING is always globally defined, which implies that all functions, regardless of whether foo.DLL or bar.DLL is being built, are given the attribute __declspec(dllexport) and are never given __declspec(dllimport). In fact, even the main executable has them defined with dllexport.

 

If you comment the add_definitions() line out, then you will get the desired behaviour I was trying to explain, where dllexport only gets defined when the library in question is being built.

 

This is the compilation log from MSVC10 when _BUILDING is globally defined:

 

2>------ Build started: Project: foo, Configuration: Debug Win32 ------
2>Build started 19/02/2015 00:07:57.
2>PrepareForBuild:
2>  Creating directory "C:\Users\thecomet\Desktop\dll-example\build\bin\Debug\".
2>InitializeBuildStatus:
2>  Creating "foo.dir\Debug\foo.unsuccessfulbuild" because "AlwaysCreate" was specified.
2>CustomBuild:
2>  Building Custom Rule C:/Users/thecomet/Desktop/dll-example/foo/CMakeLists.txt
2>  CMake does not need to re-run because C:\Users\thecomet\Desktop\dll-example\build\foo\CMakeFiles\generate.stamp is up-to-date.
2>MakeDirsForCl:
2>  Creating directory "C:\Users\thecomet\Desktop\dll-example\build\foo\Debug".
2>ClCompile:
2>  foo.c
2>MakeDirsForLink:
2>  Creating directory "C:\Users\thecomet\Desktop\dll-example\build\lib\Debug\".
2>Link:
2>     Creating library C:/Users/thecomet/Desktop/dll-example/build/lib/Debug/foo.lib and object C:/Users/thecomet/Desktop/dll-example/build/lib/Debug/foo.exp
2>LinkEmbedManifest:
2>     Creating library C:/Users/thecomet/Desktop/dll-example/build/lib/Debug/foo.lib and object C:/Users/thecomet/Desktop/dll-example/build/lib/Debug/foo.exp
2>  foo.vcxproj -> C:\Users\thecomet\Desktop\dll-example\build\bin\Debug\foo.dll
2>FinalizeBuildStatus:
2>  Deleting file "foo.dir\Debug\foo.unsuccessfulbuild".
2>  Touching "foo.dir\Debug\foo.lastbuildstate".
2>
2>Build succeeded.
2>
2>Time Elapsed 00:00:00.82
3>------ Build started: Project: bar, Configuration: Debug Win32 ------
3>Build started 19/02/2015 00:07:58.
3>InitializeBuildStatus:
3>  Creating "bar.dir\Debug\bar.unsuccessfulbuild" because "AlwaysCreate" was specified.
3>CustomBuild:
3>  Building Custom Rule C:/Users/thecomet/Desktop/dll-example/bar/CMakeLists.txt
3>  CMake does not need to re-run because C:\Users\thecomet\Desktop\dll-example\build\bar\CMakeFiles\generate.stamp is up-to-date.
3>MakeDirsForCl:
3>  Creating directory "C:\Users\thecomet\Desktop\dll-example\build\bar\Debug".
3>ClCompile:
3>  bar.c
3>Link:
3>     Creating library C:/Users/thecomet/Desktop/dll-example/build/lib/Debug/bar.lib and object C:/Users/thecomet/Desktop/dll-example/build/lib/Debug/bar.exp
3>LinkEmbedManifest:
3>     Creating library C:/Users/thecomet/Desktop/dll-example/build/lib/Debug/bar.lib and object C:/Users/thecomet/Desktop/dll-example/build/lib/Debug/bar.exp
3>  bar.vcxproj -> C:\Users\thecomet\Desktop\dll-example\build\bin\Debug\bar.dll
3>FinalizeBuildStatus:
3>  Deleting file "bar.dir\Debug\bar.unsuccessfulbuild".
3>  Touching "bar.dir\Debug\bar.lastbuildstate".
3>
3>Build succeeded.
3>
3>Time Elapsed 00:00:00.75
4>------ Build started: Project: app, Configuration: Debug Win32 ------
4>Build started 19/02/2015 00:07:59.
4>InitializeBuildStatus:
4>  Creating "app.dir\Debug\app.unsuccessfulbuild" because "AlwaysCreate" was specified.
4>CustomBuild:
4>  Building Custom Rule C:/Users/thecomet/Desktop/dll-example/CMakeLists.txt
4>  CMake does not need to re-run because C:\Users\thecomet\Desktop\dll-example\build\CMakeFiles\generate.stamp is up-to-date.
4>ClCompile:
4>  app.c
4>LinkEmbedManifest:
4>  app.vcxproj -> C:\Users\thecomet\Desktop\dll-example\build\bin\Debug\app.exe
4>FinalizeBuildStatus:
4>  Deleting file "app.dir\Debug\app.unsuccessfulbuild".
4>  Touching "app.dir\Debug\app.lastbuildstate".
4>
4>Build succeeded.
4>
4>Time Elapsed 00:00:00.78

As you can see, the compiler doesn't seem to care that everything was declared with dllexport. Why?


In Topic: dllimport/dllexport with multiple depending shared libs

18 February 2015 - 03:32 PM


It'd be handy if you could show this magic "global export.h" - I'm not sure what that means.

:

I'll rephrase my questions, as they were a little confusing.

 

Situation: bar.DLL links against foo.DLL.

1) While bar.DLL is building, do I need to dllexport bar's functions and dllimport foo's functions?
2) If 1) is true, why do I not get any linker errors when bar.DLL is building and I dllexport foo's functions instead of dllimporting them?

 

That's all I'm really asking.


In Topic: What are the recommended places to store save data?

17 February 2015 - 07:26 AM

I really wish it was standardized and had to be placed in one spot. Nothing is more annoying to me than having to search many folders for save games when I do a system wipe. I wanna be able to copy one folder and grab all my game saves etc to move

It is standardized. On Windows you just copy your %appdata% folder. On linux and mac everything is in your home folder.


In Topic: What are the recommended places to store save data?

16 February 2015 - 06:21 PM


Call me old-school but whatever happened to storing system configuration in /etc?

/etc is for system configurations, user application configurations go into /usr/local/share or /usr/share if they are not to be touched by the user.


In Topic: What are the recommended places to store save data?

16 February 2015 - 04:06 PM

On Windows machines it's best to place savefiles in %appdata%. Depending on the situation you can also place them directly in the home folder for them to be more accessible to the end user.

 

On Linux there are a few locations, most applications put user created content in ~/.local/share/<app_name>/ and user configuration files in ~/.config/<app_name>/. System configurations (things the user shouldn't touch) are usually placed in /usr/local/share/<app_name>/. Again, depending on the situation, you may also want to place user files directly in the home folder ~/.

 

I am not sure what mac does.


PARTNERS