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

error: unresolved external symbol; some libraries may be wrong? #1

Open
blue-devil opened this issue Aug 18, 2022 · 2 comments
Open

Comments

@blue-devil
Copy link

Hello @mrfearless , how'r you doin'?

I have setup RadASM with UASM. I had issues if i use libraries in this repo.

Platform:
OS : Windows 10 x64
IDE : RasASM v2.2.2.3

Assembler : UASM v2.55
Assembler PATH : C:\UASM
Library Path : C:\UASM\Lib\x64

Sample MessageBox Code
I have created a new project under RadASM UASM64 -> WIN64 -> Without template and pasted the code

;--- Win64 "hello world" GUI application.
;--- assemble: 

    option casemap:none

    includelib kernel32.lib
    includelib user32.lib

externdef MessageBoxA : near
externdef ExitProcess : near

    .data

text    db 'Hello world!', 0
caption db 'Hello x86-64', 0

    .code

OPTION PROC:NONE
main proc
    sub rsp, 28h        ; space for 4 arguments + 16byte aligned stack
    xor r9d, r9d        ; 4. argument: r9d = uType = 0
    lea r8, [caption]   ; 3. argument: r8  = caption
    lea rdx, [text]     ; 2. argument: edx = window text
    xor rcx, rcx        ; 1. argument: rcx = hWnd = NULL
    call MessageBoxA
    xor ecx, ecx        ; ecx = exit code
    call ExitProcess
main endp

    end

RADASM OUTPUT
Then I hit the build button

\UASM\Bin\UASM64.exe /c -win64 -Zp8 /win64 /D_WIN64 /Cp /nologo /W2 /I"\UASM\Include" "GUI-MessageBox.asm"
GUI-MessageBox.Asm: 36 lines, 2 passes, 1 ms, 0 warnings, 0 errors
\UASM\Bin\LINK.EXE /SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0 /MACHINE:X64 /LIBPATH:"\UASM\Lib\x64" /OUT:"GUI-MessageBox.exe" "GUI-MessageBox.obj" "GUI-MessageBox.res"
Microsoft (R) Incremental Linker Version 12.00.31101.0
Copyright (C) Microsoft Corporation.  All rights reserved.

\UASM\Lib\x64\kernel32.lib : warning LNK4003: invalid library format; library ignored
\UASM\Lib\x64\user32.lib : warning LNK4003: invalid library format; library ignored
GUI-MessageBox.obj : error LNK2019: unresolved external symbol MessageBoxA referenced in function main
GUI-MessageBox.obj : error LNK2019: unresolved external symbol ExitProcess referenced in function main
LINK : error LNK2001: unresolved external symbol WinMainCRTStartup
GUI-MessageBox.exe : fatal error LNK1120: 3 unresolved externals

Make error(s) occured.
Total compile time 187 ms

So I changed the library path to one of my windows sdk's and build again(i also added /ENTRY:main)

\UASM\Bin\UASM64.exe /c -win64 -Zp8 /win64 /D_WIN64 /Cp /nologo /W2 /I"\UASM\include" "GUI-MessageBox.asm"
GUI-MessageBox.Asm: 36 lines, 2 passes, 1 ms, 0 warnings, 0 errors
\UASM\Bin\LINK.EXE /SUBSYSTEM:WINDOWS /RELEASE /VERSION:4.0 /MACHINE:X64 /ENTRY:main /LIBPATH:"C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib\x64" /OUT:"GUI-MessageBox.exe" "GUI-MessageBox.obj" "GUI-MessageBox.res"
Microsoft (R) Incremental Linker Version 12.00.31101.0
Copyright (C) Microsoft Corporation.  All rights reserved.


Make finished.
Total compile time 187 ms

So what is the problem.
I have checked several lib files in this repo -like kernel32 and user32- and they are slightly problematic. For example we can open a lib file with 7zip. Because they are a kind of archive files. you cannot open kernel32.lib and user32.lib in your this repo. But also there are some libraries are working like msvcrt.lib

We can also use detect-it-easy for cheking! If we open a normal working library with die, we get this output:

Binary
Archive: Coff library[AMD64]

But if it is a problematic library, die says:

Binary

Finally -maybe temporary- workaround is using library files under windows sdk!

@mrfearless
Copy link
Owner

mrfearless commented Aug 18, 2022 via email

@blue-devil
Copy link
Author

OK this is sooo interesting; if i clone the repo, all the libs are working, NO PROBLEM

BUT, if i download latest tag or download repo as ZIP, the libraries are becoming broken! All the LF - LineFeeds become CarriageReturnLineFeed - CRLF; WHY? And there are exceptions(like i told above).

Unfortunately, I don't know how to fix this? You can close it if you want @mrfearless

BTW, -temp solution- cloning the repo, eliminates the problem.

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

2 participants