Overview
Examples
Screenshots
Comparisons
Applications
Download
Documentation
Tutorials
Bazaar
Status & Roadmap
FAQ
Authors & License
Forums
Funding Ultimate++
Search on this site
Search in forums












SourceForge.net Logo
Home » U++ Library support » U++ Core » CreateSymbolicLink doesn't compile using MinGW
CreateSymbolicLink doesn't compile using MinGW [message #49145] Tue, 26 December 2017 11:53 Go to next message
_dka_ is currently offline  _dka_
Messages: 2
Registered: December 2017
Junior Member
Hello all,

Sorry, i use google translator.
I used upp-mingw (last nightly builds and stable upp-mingw-11540).
I want to create a symbolic link to a folder.
I tried to create console applications in projects of different types.

My source (Core console project):

#include <Core/Core.h>
using namespace Upp;
CONSOLE_APP_MAIN
{
	CreateSymbolicLink("","",1);
}


Compiler error:

MyApps_MkLinks.cpp (7): error: 'CreateSymbolicLink' was not declared in this scope
 (): CreateSymbolicLink("","",1);
MyApps_MkLinks.cpp (7): note: suggested alternative: 'CreateHardLink'
 (): CreateSymbolicLink("","",1);
 (): CreateHardLink


So far, I've solved this problem by adding lines from the winbase.h from mingw:

#include <Core/Core.h>
using namespace Upp;

#define SYMBOLIC_LINK_FLAG_DIRECTORY (0x1)
WINBASEAPI BOOLEAN APIENTRY CreateSymbolicLinkA ( LPCSTR lpSymlinkFileName, LPCSTR lpTargetFileName, DWORD dwFlags );
WINBASEAPI BOOLEAN APIENTRY CreateSymbolicLinkW ( LPCWSTR lpSymlinkFileName, LPCWSTR lpTargetFileName, DWORD dwFlags );
#define CreateSymbolicLink __MINGW_NAME_AW(CreateSymbolicLink)

CONSOLE_APP_MAIN
{
	CreateSymbolicLink("","",1);
}


but now there is a link error:

 (): Linking has failed
 (): MyApps_MkLinks/MINGW.Debug.Debug_Full.Main.Noblitz\MyApps_MkLinks.o: In function `Z14ConsoleMainFn_
v':
MyApps_MkLinks/MyApps_MkLinks.cpp (40): undefined reference to `_imp___Z19CreateSymbolicLinkAPKcS0_m@12'
 (): collect2.exe: error: ld returned 1 exit status


Build methods settings:

[Updated on: Tue, 26 December 2017 14:22]

Report message to a moderator

Re: CreateSymbolicLink doesn't compile using MinGW [message #49146 is a reply to message #49145] Tue, 26 December 2017 17:57 Go to previous messageGo to next message
Klugier is currently offline  Klugier
Messages: 1076
Registered: September 2012
Location: Poland, Kraków
Senior Contributor
Hello,

The compilation error occurred, because you are trying to use WinAPI without including header appropriate header. In your case it is winbase.h. Please notice that by including Core.h system header is never inherit. Core library must work in multi-platform environment, so doing such a thing would be bad.

Moreover when you decide to use CreateSymbolicLink your application will not compile on other platforms such as Linux without modification or writing ifdef blocks.

As far as I know U++ doesn't offer support for SymLink, but i might be wrong.

Sincerely,
Klugier


U++ - one framework to rule them all.
Re: CreateSymbolicLink doesn't compile using MinGW [message #49147 is a reply to message #49146] Tue, 26 December 2017 18:13 Go to previous message
_dka_ is currently offline  _dka_
Messages: 2
Registered: December 2017
Junior Member
Thank you )

I found that in the Core.h file winbase.h is included under the condition
#ifdef COMPILER_MSC
    #include <winbase.h>

The question is closed.
Previous Topic: ParseJSON now throws exception
Next Topic: _mm_pause not defined
Goto Forum:
  


Current Time: Fri Apr 19 10:30:44 CEST 2024

Total time taken to generate the page: 0.04901 seconds