Author Topic: UASM - Linux Examples  (Read 1347 times)

LiaoMi

  • Member
  • ****
  • Posts: 697
UASM - Linux Examples
« on: February 24, 2019, 08:49:53 PM »
Good morning(We have morning here  :biggrin:),

I am studying examples of Linux programs that are attached to the project. I chose two examples - Linux4a.asm, Linux4d.asm. Just want to say that I work under Windows, I have installed Msys64 with support for 32 bit code. UASM (2.47.1) compiled all source code as needed, but when I try to complete the build via ld or gcc, I get errors

Code: [Select]
Microsoft Windows [Version 10.0.17134.472]
(c) 2018 Microsoft Corporation. All rights reserved.

c:\msys64\mingw32\bin>ld -s -shared -o Linux4d.so Linux4d.o
ld: cannot export getstring: symbol not found

c:\msys64\mingw32\bin>gcc -s -shared -o Linux4d.so Linux4d.o
c:/msys64/mingw32/bin/../lib/gcc/i686-w64-mingw32/7.3.0/../../../../i686-w64-mingw32/bin/ld.exe: cannot export getstring: symbol not found
collect2.exe: error: ld returned 1 exit status

c:\msys64\mingw32\bin>ld -s -shared -soname libLinux4d.so.1 -o libLinux4d.so.1.0 Linux4d.o
ld: cannot export getstring: symbol not found

c:\msys64\mingw32\bin>

What is the cause of the problem?  :icon_redface:  :icon_confused:

Vortex

  • Member
  • *****
  • Posts: 2282
Re: UASM - Linux Examples
« Reply #1 on: February 24, 2019, 09:11:35 PM »
Hi LiaoMi,

My apologies if I am wrong but .so files ( shared objects ) are specific to Linux. They are like DLLs in Windows.

LiaoMi

  • Member
  • ****
  • Posts: 697
Re: UASM - Linux Examples
« Reply #2 on: February 24, 2019, 09:20:52 PM »
Hi LiaoMi,

My apologies if I am wrong but .so files ( shared objects ) are specific to Linux. They are like DLLs in Windows.

Hi Vortex,

It is right ..
Quote
A .a file is a static library, while a .so file is a shared object (dynamic) library similar to a DLL on Windows.

Are you hinting at the fact that I can not build .so file under windows using gcc, am I right?

KradMoonRa

  • Member
  • **
  • Posts: 52
Re: UASM - Linux Examples
« Reply #3 on: February 24, 2019, 09:32:43 PM »
Hi,

Normally ld allow to export everything without a need for a export .def file like vc under windows.

But I cant find the example You talking to check the files.

Your's project is using function getstring(), but the compiler link time cant decipher were it is!

And yes You can cross compile for linux with mingw and clang, but system functions aren't available if You don't have the linux header libs and libs itself.

LiaoMi

  • Member
  • ****
  • Posts: 697
Re: UASM - Linux Examples
« Reply #4 on: February 24, 2019, 09:44:50 PM »
Hi,

Normally ld allow to export everything without a need for a export .def file like vc under windows.

But I cant find the example You talking to check the files.

Your's project is using function getstring(), but the compiler link time cant decipher were it is!

And yes You can cross compile for linux with mingw and clang, but system functions aren't available if You don't have the linux header libs and libs itself.

Hi KradMoonRa,

I also thought so, but how is it in reality .. All examples are in the zip release of UASM - Samples\Linux32\Linux4d.asm

KradMoonRa

  • Member
  • **
  • Posts: 52
Re: UASM - Linux Examples
« Reply #5 on: February 24, 2019, 11:12:48 PM »
Hi,

Ok I see,

MinGW aren't cross compiling for linux, normally its not necessary to pass nothing more than the object file name, but the MinGW aren't cross compiling till You add some linux cross tool chain for windows. Or use clang itself, to produce unix version of the object files.

Some directions for clang
https://clang.llvm.org/docs/CrossCompilation.html

And here for MinGW cross tools
http://www.mingw.org/wiki/linuxcrossmingw

LiaoMi

  • Member
  • ****
  • Posts: 697
Re: UASM - Linux Examples
« Reply #6 on: February 25, 2019, 12:23:25 AM »
 :t

Code: [Select]
$ pacman -S mingw-w64-cross-toolchain mingw-w64-cross
:: There are 9 members in group mingw-w64-cross-toolchain:
:: Repository msys
   1) mingw-w64-cross-binutils  2) mingw-w64-cross-crt-git  3) mingw-w64-cross-gcc
   4) mingw-w64-cross-headers-git  5) mingw-w64-cross-tools-git
   6) mingw-w64-cross-windows-default-manifest  7) mingw-w64-cross-winpthreads-git
   8) mingw-w64-cross-winstorecompat-git  9) mingw-w64-cross-zlib

Enter a selection (default=all):
:: There are 9 members in group mingw-w64-cross:
:: Repository msys
   1) mingw-w64-cross-binutils  2) mingw-w64-cross-crt-git  3) mingw-w64-cross-gcc
   4) mingw-w64-cross-headers-git  5) mingw-w64-cross-tools-git
   6) mingw-w64-cross-windows-default-manifest  7) mingw-w64-cross-winpthreads-git
   8) mingw-w64-cross-winstorecompat-git  9) mingw-w64-cross-zlib

Enter a selection (default=all):

Code: [Select]
Packages (11) isl-0.19-1  mpc-1.1.0-1  mingw-w64-cross-binutils-2.30-1
              mingw-w64-cross-crt-git-6.0.0.5141.696b37c3-1  mingw-w64-cross-gcc-7.3.0-2
              mingw-w64-cross-headers-git-6.0.0.5141.696b37c3-1
              mingw-w64-cross-tools-git-6.0.0.5141.696b37c3-1
              mingw-w64-cross-windows-default-manifest-6.4-2
              mingw-w64-cross-winpthreads-git-6.0.0.5142.0b647fe7-1
              mingw-w64-cross-winstorecompat-git-6.0.0.5099.5e5f06f6-1  mingw-w64-cross-zlib-1.2.11-1

Total Download Size:    79.61 MiB
Total Installed Size:  602.40 MiB

:: Proceed with installation? [Y/n] y
:: Retrieving packages...
 mingw-w64-cross-binutils-2.30-1-...     5.5 MiB  1005K/s 00:06 [##################################] 100%
 mingw-w64-cross-headers-git-6.0....    14.2 MiB  2.64M/s 00:05 [##################################] 100%
 mingw-w64-cross-crt-git-6.0.0.51...     4.7 MiB  2.10M/s 00:02 [##################################] 100%
 mpc-1.1.0-1-x86_64                     74.1 KiB  2.19M/s 00:00 [##################################] 100%
 isl-0.19-1-x86_64                     485.7 KiB  1833K/s 00:00 [##################################] 100%
 mingw-w64-cross-winpthreads-git-...   273.6 KiB  2.81M/s 00:00 [##################################] 100%
 mingw-w64-cross-windows-default-...    13.2 KiB  1103K/s 00:00 [##################################] 100%
 mingw-w64-cross-gcc-7.3.0-2-x86_64     53.6 MiB  2.26M/s 00:24 [##################################] 100%
 mingw-w64-cross-tools-git-6.0.0....   423.6 KiB   370K/s 00:01 [##################################] 100%
 mingw-w64-cross-winstorecompat-g...   111.5 KiB  2.87M/s 00:00 [##################################] 100%
 mingw-w64-cross-zlib-1.2.11-1-x86_64  187.4 KiB  2.08M/s 00:00 [##################################] 100%
(11/11) checking keys in keyring                                [##################################] 100%
(11/11) checking package integrity                              [##################################] 100%
(11/11) loading package files                                   [##################################] 100%
(11/11) checking for file conflicts                             [##################################] 100%
(11/11) checking available disk space                           [##################################] 100%
:: Processing package changes...
( 1/11) installing mingw-w64-cross-binutils                     [##################################] 100%
( 2/11) installing mingw-w64-cross-headers-git                  [##################################] 100%
( 3/11) installing mingw-w64-cross-crt-git                      [##################################] 100%
( 4/11) installing mpc                                          [##################################] 100%
( 5/11) installing isl                                          [##################################] 100%
( 6/11) installing mingw-w64-cross-winpthreads-git              [##################################] 100%
( 7/11) installing mingw-w64-cross-windows-default-manifest     [##################################] 100%
( 8/11) installing mingw-w64-cross-gcc                          [##################################] 100%
( 9/11) installing mingw-w64-cross-tools-git                    [##################################] 100%
(10/11) installing mingw-w64-cross-winstorecompat-git           [##################################] 100%
(11/11) installing mingw-w64-cross-zlib                         [##################################] 100%

The installation is complete, it will be more interesting, since it is not clear how to enter the link parameters correctly  :eusa_dance: