Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Programming \ Create a DLL using MinGW and Attention     - grep, egrep and regular expressions (Linux)

- Java filter (Programming)

- Linux system security (Linux)

- C ++, overloading, cover, hide (Programming)

- CentOS install SystemTap-2.6 (Linux)

- How to configure security management services under Linux (Linux)

- VMware virtual machine can not start VMnet0 no Internet access and other issues (Linux)

- PyCharm new Python file name and the name of the module will import the same problem might arise (Programming)

- ogg Oracle to SQL Server 2005 to achieve synchronization (Database)

- GitLab issued Merge Request return error 500 when the two solutions log (Linux)

- Ubuntu Series Installation Docker (Linux)

- Linux SSH login without a password (Linux)

- How to install new fonts on Ubuntu 14.04 and 14.10 (Linux)

- Linux uses the SMTP proxy to send mail (Linux)

- Large site architecture study notes (Server)

- Hadoop - Task Scheduling System Comparison (Server)

- CentOS-based Kickstart automated installation practice (Linux)

- Let OS X support NTFS write file (Linux)

- Perl said method B if A judge (Programming)

- df show disk space usage (Linux)

 
         
  Create a DLL using MinGW and Attention
     
  Add Date : 2018-11-21      
         
         
         
  MinGW is a Windows version of GCC, has come to the stable version 4.5.2, the functionality and performance is very good, feeling better than Microsoft's own VC difference ah. But under MinGW'd pay special attention to the use and creation of DLL, the problem is mainly concentrated in the g ++ compiler (C ++ the GNU version of the compiler) for the function of the input of the DLL and the name of the output modification on the call protocol and VC compiler is a big difference of.

1, MinGW how to use a standard DLL. Here the standard DLL refers to the use __stdcall calling protocol, and export the clean function name, no function name tail @nn, no function names head underlined. MinGW's g ++ program, for the function to be imported from a DLL, you must use declared extern "C", but do not use __declspec (dllimport), although g ++ support, but once you use the g ++ link will automatically forced to be imported before the function name plus _imp__ prefix, resulting in a function name can not be found error link. So, in fact, we do not need to use __declspec (dllimport). On the other hand, gcc / g ++ compiler encounters code __stdcall qualified function name, the function name will automatically be set at link time as a function name @ nn, nn is a function of the parameter stack bytes. Also, gcc / g ++ compiler / linker at link time did not really need the DLL's import library (import lib), because they can link directly from the DLL, so more convenient, save a lot of how to generate a form from the DLL requirements. importing a library and other issues. Only need to add -Wl in gcc / g ++ parameters, - enable-stdcall-fixup -L ../../ Bin / -lDLL file name (excluding .dll) to complete the link directly from the DLL file itself. Here we must note, -Wl parameter indicates g ++ linker need to use back link control parameters (separated by commas), - enable-stdcall-fixup tells g ++ linker need to import a DLL function name to be automatically added at the end @nn suffix format, in order to comply with gcc / g ++ function name for __stdcall extended specifications. -L Directory specified DLL file, -l specify the DLL file name, without the .dll. If you do not add --enable-stdcall-fixup, gcc / g ++ link error will always be reported, because gcc / g ++ function names will be behind the code needed to import from a DLL are forcibly added @nn, but the DLL function name does not with @nn, no --enable-stdcall-fixup, is likely to be wrong. Instant no mistake, there will be a lot of warning, it is likely to cause the program to crash! Note, in the NetBeans CDT, -Wl, - such parameters enable-stdcall-fixup -L -l is specified in the linker parameter settings.

2, MinGW how to create a standard DLL. MinGW create a standard DLL, you should use __declspec (dllexport), including the extern "C" and VC are all the same. Note, however, so the compiler links generated DLL, exported function names are the tail with @nn, in order to remove them, you must use -Wl link parameter settings, - kill-at, it tells the linker to create DLL when you export a function name without trailing with @nn. Note, in NetBeans CDT, and above this parameter is also specified in the linker parameter settings.

In summary, if you create a DLL, this DLL at the same time we need to import additional DLL function parameters can be unified -Wl, - kill-at, - enable-stdcall-fixup -L -l like this, and very convenient. MinGW really feel quite powerful, cross-platform, very flexible and adjustable, the performance is very strong, even more valuable is that it is a free and powerful compiler! Of course, with NetBeans CDT it is a very good C / C ++ development tool.

Program or DLL MinGW created from libgcc-xx-xx.dll and libstdc ++ - runtime method x.dll

MinGW followed under Linux gcc / g ++ habit of compiling a program or dynamic link library (shared library) always default to dynamic linking, the system needs included run-time library file libgcc-xx-xx.dll and libstdc ++ - xx .dll. So if we do not want to have to run that came with these two libraries publisher, how does it work? By reference to the gcc / g ++ User Manual, found that only need to use the -static-libgcc and -static-libstdc ++ compiler or linker parameter settings to achieve this static library to link two runtime, the library does not have to run incidental. If parameter -static, it means that all involved have adopted the external shared library statically linked way up. But always MinGW or to rely on this basic msvcrt.dll runtime on a Windows platform, it is believed that any Windows platform will not be less msvcrt.dll this document, it is inevitable that comes with Windows system files friends.
     
         
         
         
  More:      
 
- Install Ruby on Rails in Ubuntu 15.04 in (Linux)
- Nodejs mysql pool Example (Programming)
- MySQL migration tool used in the production environment (Database)
- Update GAMIT10.6 command (Linux)
- pscp use Detailed Windows and Linux each file transfer tool (Linux)
- CentOS 6.7 compile and install LAMP (Server)
- Bash Automated Customization Linux belongs to its own CentOS system (Linux)
- How to install Ubuntu applications Device 7 (Linux)
- How to download apk file from the Google Play store on Linux (Linux)
- Linux ./configure --prefix command (Linux)
- MySQL concat function is SQL injection (Linux)
- Linux desktop system using the remote server in clear text ssh password (Server)
- Linux disk partition, format, mount the directory (Linux)
- Gitolite how to import other Git repositories (Server)
- Through the source code to install MySQL 5.6.26 under CentOS6 (Database)
- Oracle multi-table query optimization (Database)
- Lua study notes under ubuntu (Linux)
- Linux iptables firewall settings (Linux)
- Oracle 11g through SCN do incremental backup repair standby library detailed process (Database)
- Linux Firewall Builder shorewall (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.