Hey guys,
I searched the archives and googled, but, couldn't find the answer. :boohoo:
A few years ago I built a project based on Masm32, but, (due to license restrictions) I'm looking to convert the project over to JWasm.
What I would like to know is can JWasm successfully use mingw headers (converted to *.inc) and library (*.a) files ?
JWasm comes with h2incx.exe for converting the headers to ".inc" files, but, I'm not sure what to do with the libraries.
Does anyone know, are they usable as they are ?
Is there a better alternative ?
JWasm comes with some common ".inc" and ".lib" files, but, not most and certainly not as many as MSVC.
Funny thing, there is a conversion program out there called "lib2a.exe" (that does what its name implies) but, there appears to be no "a2lib.exe". :'(
i seem to recall that Andreas had a batch file to build the import libraries
http://www.japheth.de/WinInc.html#widownload
there are some additional (less commonly used) includes in WinIncEx
Steve,
Download Pelles C as it has very good command line tools, lib, link etc ... You can use them to make your own set of libraries that are fully compatible with MASM and therefore probably JWASM.
Hello,
Quote from: SteveAsm on October 27, 2011, 02:40:09 PM
Hey guys,
I searched the archives and googled, but, couldn't find the answer. :boohoo:
A few years ago I built a project based on Masm32, but, (due to license restrictions) I'm looking to convert the project over to JWasm.
As Dave said, download and get yourself accustomed to WinInc.
In WinInc, C header == ASM header.
Quote from: SteveAsm on October 27, 2011, 02:40:09 PM
What I would like to know is can JWasm successfully use mingw headers (converted to *.inc) and library (*.a) files ?
Jwasm does not use ".a" files, those files are .obj collections for the linker.
Quote from: SteveAsm on October 27, 2011, 02:40:09 PM
I'm not sure what to do with the libraries.
Nothing. Jwasm does not use libraries.
Quote from: SteveAsm on October 27, 2011, 02:40:09 PM
Is there a better alternative ?
JWASM+MinGW+WinInc+(Radasm or Code::Blocks) = complete C/C++/ASM environment
NOT TO MENTION THAT GCC SUPPORTS THE DAMN C99 AND MSVC DOES NOT!
Quote from: dedndave on October 27, 2011, 03:13:12 PM
i seem to recall that Andreas had a batch file to build the import libraries
http://www.japheth.de/WinInc.html#widownload
there are some additional (less commonly used) includes in WinIncEx
Hey Dave,
yeh, I used the *.DEF files, (found in ..\WinInc\Def\), with polib.exe to produce the Lib files, but, I don't know how to expand on that.
The number of *.lib's is very limited.
I was looking to add several more libs to the mix.
Steve
edit:
just downloaded the WinIncEx.
Quote from: hutch-- on October 27, 2011, 03:20:33 PM
Download Pelles C as it has very good command line tools, lib, link etc ...
Hey Hutch,
Yes, I do have Pelles C.
I used polib.exe to create the original ".Lib" files for JWasm from the ".DEF" files.
Steve
jwasm does not use libraries.
Quote from: drizz on October 27, 2011, 04:37:59 PM
jwasm does not use libraries.
Hey drizz,
then, I don't understand this JWasm Readme.txt:
Quoteif this directory is empty (or contains just UUID.LIB), view
..\Def\Readme.txt how to create the most important Win32 import libraries.
Are we talking about the same thing ?
steve
The files for generating .lib files are probably there for environments like "Visual C++ Toolkit 2003" that don't come with PSDK libraries ( kernel32 user32 ). Since kernel32 user32 etc. libs need only to contain function import definitions (No code), they can easily be built from .def files.
Decide what environment you want to use. PellesC comes with OS libraries, MinGW comes with OS libraries, VCToolkit2003 does not.
Hi SteveAsm,
Attached is a zip file containing all the .def files from the GeneSys project. You can find the missing .def files to build your import libraries.
Concerning MinGW import libraries, I remember that Polink can use them but those import libraries have different kind of MS COFF relocation information if I am not wrong.
Quote from: Vortex on October 27, 2011, 05:53:25 PM
Attached is a zip file containing all the .def files from the GeneSys project. You can find the missing .def files to build your import libraries.
Concerning MinGW import libraries, I remember that Polink can use them but those import libraries have different kind of MS COFF relocation information if I am not wrong.
Thanks for the link and the info Vortex. :thumbu
steve
Quote from: SteveAsm on October 27, 2011, 04:35:01 PMYes, I do have Pelles C.
I used polib.exe to create the original ".Lib" files for JWasm from the ".DEF" files.
Why would you build .lib files when you have them in "c:\Program Files\PellesC\Lib\Win\"
Quote from: Vortex on October 27, 2011, 05:53:25 PMConcerning MinGW import libraries, I remember that Polink can use them but those import libraries have different kind of MS COFF relocation information if I am not wrong.
Why would you use POLINK with MINGW libs when you have LD.
Quote from: drizz on October 27, 2011, 06:33:42 PM
Why would you use POLINK with MINGW libs when you have LD.
Polink is easier to use and compatible with other development tools.
I just assumed MinGW was elf format on Windows?
These are the two batch files I am using with jwasm and MinGW.
console:
@setlocal
@ECHO OFF
@SET MINGW=C:\MinGW
@SET LIB=%MINGW%\lib -Lc:\jwasm\bxbasm\lib
@SET INCLUDE=%MINGW%\include;%MINGW%\include\sys
@SET PATH=C:\jwasm;C:\jwasm\jwlink;%MINGW%\bin;%PATH%
@SET GCCCFL= --format elf32-i386 --subsystem console
jwasm -elf %1.asm
ld %GCCCFL% -s -o %1.exe %1.obj -L%LIB% -lbxbasmlib -lmingw32 -lmsvcrt -lkernel32 -luser32 -lgdi32 -lcomctl32 -ladvapi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lwinmm -lcomdlg32 -limagehlp -lversion
REM ECHO All Done
endlocal
gui
@setlocal
@SET MINGW=C:\MinGW
@SET LIB=%MINGW%\lib -Lc:\jwasm\bxbasm\lib
@SET INCLUDE=%MINGW%\include;%MINGW%\include\sys
@SET PATH=C:\jwasm;C:\jwasm\jwlink;%MINGW%\bin;%PATH%
@SET GCCCFL= --format elf32-i386 --subsystem windows
@jwasm -elf %1.asm
@ld %GCCCFL% -s -o %1.exe %1.obj -L%LIB% -lmingw32 -lmsvcrt -lkernel32 -luser32 -lgdi32 -lcomctl32 -ladvapi32 -lwinspool -lshell32 -lole32 -loleaut32 -luuid -lodbc32 -lodbccp32 -lwinmm -lcomdlg32 -limagehlp -lversion
ECHO All Done
James
Quote from: Vortex on October 27, 2011, 06:40:48 PM
Quote from: drizz on October 27, 2011, 06:33:42 PM
Why would you use POLINK with MINGW libs when you have LD.
Polink is easier to use and compatible with other development tools.
Why mentioning the use of MINGW libs at all then? PellesC package has its own lib files.
Hi SteveAsm,
lib2def (http://www.masm32.com/board/index.php?topic=4850.0) can convert a MinGW import library to a module definition file :
lib2def.exe libkernel32.a
ren libkernel32.def kernel32.def
QuoteWhy mentioning the use of MINGW libs at all then? PellesC package has its own lib files.
Hi drizz,
You are right but it has been asked to use \ convert MinGW import libraries. The MinGW package provides more libraries and they can be converted to MS \ Pelles C import libraries.
Quote from: Vortex on October 27, 2011, 07:55:24 PMYou are right but it has been asked to use \ convert MinGW import libraries.
And I have been telling constantly that jwasm does not use libraries.
Quote from: drizz on October 27, 2011, 08:11:42 PM
And I have been telling constantly that jwasm does not use libraries.
Huh.
Can someone confirm that ?
I didn't see that written down anywhere.
steve
Quote from: Vortex on October 27, 2011, 07:51:20 PM
lib2def can convert a MinGW import library to a module definition file :
Hey thanks for the link Vortex.
This could come in quite handy.
steve
Quote from: jcfuller on October 27, 2011, 07:18:13 PM
I just assumed MinGW was elf format on Windows?
These are the two batch files I am using with jwasm and MinGW.
So James,
you are using them both (Include and Lib files) right out of the box ?
Without any conversion ?
That is to say: *.h and *.a .
For use with jwasm, it appear that they would need to be converted to *.inc and *.lib.
That is the question.
Steve,
when you use
INCLUDE \masm32\include\kernel32.inc
it adds additional lines to the assembly source
when you use
INCLUDELIB \masm32\lib\kernel32.lib
it tells the assembler where to resolve external references
however, this is really telling the linker (via the OBJ file), where to resolve external references
Quote from: SteveAsm on October 27, 2011, 09:05:17 PM
Quote from: drizz on October 27, 2011, 08:11:42 PM
And I have been telling constantly that jwasm does not use libraries.
Huh.
Can someone confirm that ?
I didn't see that written down anywhere.
steve
INCLUDELIB
http://msdn.microsoft.com/en-us/library/e0x6w856(v=vs.80).aspx
QuoteInforms the linker that the current module should be linked with libraryname.
The "includelib" directive just adds a "-defaultlib" command for the linker
If you do a "link /dump /all myfile.obj" and myfile contains "includelib" lines you will see something like:
SECTION HEADER #4
.drectve name
D0 physical address
0 virtual address
3D size of raw data
1AD file pointer to raw data (000001AD to 000001E9)
0 file pointer to relocation table
0 file pointer to line numbers
0 number of relocations
0 number of line numbers
A00 flags
Info
Remove
(no align specified)
RAW DATA #4
00000000: 2D 64 65 66 61 75 6C 74 6C 69 62 3A 6B 65 72 6E -defaultlib:kern
00000010: 65 6C 33 32 2E 6C 69 62 20 2D 64 65 66 61 75 6C el32.lib -defaul
00000020: 74 6C 69 62 3A 75 73 65 72 33 32 2E 6C 69 62 20 tlib:user32.lib
00000030: 2D 65 6E 74 72 79 3A 73 74 61 72 74 20 -entry:start
Linker Directives
-----------------
-defaultlib:kernel32.lib
-defaultlib:user32.lib
-entry:start
jwasm/ml does not need includelib lines to compile .asm source!You can merrily specify the needed libs only on the linker command line.
hint: see jcfullers "@ld" batch line.
Heres a step by step example:
download and unpack WinInc
mine is in dir=D:\WININC
download and install mingw, I chose TDM-GCC-MINGW64 (http://tdm-gcc.tdragon.net/download)
mine is indir=D:\MINGW64
download and unpack latest JWASM
put JWASM.EXE to
dir=D:\MINGW64\bin
put Win32_1.asm form JWASM zip to a folder of your choice.
dir=D:\Temp
optional: put MINGW\bin dir on the path so you don't have to use paths on the command line.
Example 1
step1, assemble:
D:\MINGW64\jwasm -c -coff -nologo Win32_1.asm
result:
Win32_1.asm: 45 lines, 2 passes, 0 ms, 0 warnings, 0 errors
step 2, link:
d:\MinGW64\bin\ld -m i386pe -s -o Win32_1.exe --entry mainCRTStartup --subsystem console Win32_1.obj -L"d:\MinGW64\x86_64-w64-mingw32\lib32" -lkernel32
result:
Warning: .drectve `-entry:ainCRTStartup ' unrecognized
step 3, run:
Win32_1.exe
result:
hello, world.
Another example: WinXX_1.asm as 32 bit
D:\MINGW64\bin\jwasm -c -coff -nologo -I"d:\WinInc\Include" WinXX_1.asm
d:\MinGW64\bin\ld -m i386pe -s -o WinXX_1.exe --entry _mainCRTStartup@0 --subsystem console WinXX_1.obj -L"d:\MinGW64\x86_64-w64-mingw32\lib32" -lkernel32
Another example: WinXX_1.asm as 64 bit
D:\MINGW64\bin\jwasm -c -win64 -nologo -I"d:\WinInc\Include" WinXX_1.asm
d:\MinGW64\bin\ld -m i386pep -s -o WinXX_1.AMD64.exe --entry mainCRTStartup --subsystem console WinXX_1.obj -L"d:\MinGW64\x86_64-w64-mingw32\lib" -lkernel32
Quote from: dedndave on October 27, 2011, 09:59:34 PM
when you use
INCLUDE \masm32\include\kernel32.inc
it adds additional lines to the assembly source
when you use
INCLUDELIB \masm32\lib\kernel32.lib
it tells the assembler where to resolve external references
however, this is really telling the linker (via the OBJ file), where to resolve external references
I understand this completely and I have no issue with this.
That was never a part of the question.
Quote from: drizz on October 27, 2011, 10:53:00 PM
And I have been telling constantly that jwasm does not use libraries.
Drizz, perhaps you misunderstood my intent.
When I used the term "JWasm" it was in a generic fashion.
As in, the
JWasm assembler package.
I wasn't asking how to make JWasm.exe use library files, it was more about using ".lib" versus ".a" files with the
JWasm assembler package.
Your respones that:
QuoteAnd I have been telling constantly that jwasm does not use libraries.
in the present context, can only cause confusion.
It implied that, no, you cannot use libraries with the JWasm package.
Which of course is not correct.
In the present company, I didn't think I need to be so specific as to have to specify jwlink.exe.
Sincerely
edit:
Drizz, thanks for your detailed explaination.
I have Masm32 (package) installed (as I have for many years now),
I have mingw (package) installed (as I have for many years now),
i recently installed JWasm (package).
I have been using Masm32 for many years, as well as mingw.
This is only about what from mingw can I use in conjuction with jwasm.
BTW:
Quotehint: see jcfullers "@ld" batch line.
I understand that James is linking with the mingw linker, as opposed to using the
jwlink linker.
That is not my aim.
Thanks :U
drizz, (or others)
elf vs coff opinions
James
Quote from: SteveAsm on October 28, 2011, 12:06:29 AM
Drizz, perhaps you misunderstood my intent.
When I used the term "JWasm" it was in a generic fashion.
As in, the JWasm assembler package.
I wasn't asking how to make JWasm.exe use library files, it was more about using ".lib" versus ".a" files with the JWasm assembler package.
Your respones that:
QuoteAnd I have been telling constantly that jwasm does not use libraries.
in the present context, can only cause confusion.
It implied that, no, you cannot use libraries with the JWasm package.
Which of course is not correct.
In the present company, I didn't think I need to be so specific as to have to specify jwlink.exe.
I went to japheth's site and I can't find "JWasm assembler package", care to point where it is?
I can only find : JWasm207bw.zip, WinInc202.zip, JWlinkbw.zip which are all separate packages.
Btw,
open watcom package also has win32 os libraries. I can't comment on the OW tools as I have never used them (including the modified linker from japheth), my guess is that the modified linker would work great with its originating package.
Also, since jwlink supports:
OMF the standard Intel Object Module Format, including Microsoft's 32-bit extensions
COFF both 32-bit and 64-bit variants of this format
ELF both 32-bit and 64-bit variants of this format
OMF-386 Phar Lap's 32-bit OMF variant (Easy OMF)
OMF library format
AR object library format (Microsoft, GNU or BSD compatible)
then, I think you can use anything you want, install the "Windows SDK" and use that.
Quote from: jcfuller on October 28, 2011, 12:09:49 AM
drizz, (or others)
elf vs coff opinions
James
If you mean "as jwasm.exe output format for mingw linker", my preference is to use the same format for input and output.
Steve,
I am using the WinInc files with no changes to the library files.
Using this source:
.686
.XMM
.model flat,stdcall
option casemap:none
include c:\jwasm\include\windows.inc
;includelib kernel32.lib
;includelib user32.lib
;includelib gdi32.lib
.data?
hInstance HINSTANCE ?
CommandLine LPSTR ?
.data
ClassName TCHAR "MainWinClass",0
AppName TCHAR "FirstWindow",0
.code
; ---------------------------------------------------------------------------
start:
invoke GetModuleHandle, NULL
mov hInstance,eax
invoke GetCommandLine
mov CommandLine,eax
invoke WinMain, hInstance,NULL,CommandLine, SW_SHOWDEFAULT
invoke ExitProcess,eax
WinMain proc hInst:HINSTANCE,hPrevInst:HINSTANCE,CmdLine:LPSTR,CmdShow:DWORD
LOCAL wc:WNDCLASSEX
LOCAL msg:MSG
LOCAL hwnd:HWND
mov wc.cbSize,SIZEOF WNDCLASSEX
mov wc.style, CS_HREDRAW or CS_VREDRAW
mov wc.lpfnWndProc, OFFSET WndProc
mov wc.cbClsExtra,0
mov wc.cbWndExtra,0
push hInstance
pop wc.hInstance
invoke GetStockObject,WHITE_BRUSH
mov wc.hbrBackground,EAX
mov wc.lpszMenuName,NULL
mov wc.lpszClassName,OFFSET ClassName
invoke LoadIcon,NULL,IDI_APPLICATION
mov wc.hIcon,eax
mov wc.hIconSm,eax
invoke LoadCursor,NULL,IDC_ARROW
mov wc.hCursor,eax
invoke RegisterClassEx, addr wc
invoke CreateWindowEx,
NULL,
ADDR ClassName,
ADDR AppName,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInst,
NULL
mov hwnd,eax
invoke ShowWindow, hwnd,SW_SHOWNORMAL
invoke UpdateWindow, hwnd
.while TRUE
invoke GetMessage, ADDR msg,NULL,0,0
.BREAK .if (!eax)
invoke TranslateMessage, ADDR msg
invoke DispatchMessage, ADDR msg
.endw
mov eax,msg.wParam
ret
WinMain endp
WndProc proc hWnd:HWND, uMsg:UINT, wParam:WPARAM, lParam:LPARAM
LOCAL hdc:HDC
LOCAL ps:PAINTSTRUCT
.if uMsg==WM_DESTROY
invoke PostQuitMessage,0
.elseif uMsg==WM_CREATE
.elseif uMsg == WM_PAINT
invoke BeginPaint, [hWnd], addr ps
mov [hdc], EAX
invoke EndPaint, [hWnd],addr ps
.elseif uMsg == WM_SIZE
.else
invoke DefWindowProc, hWnd, uMsg, wParam, lParam
ret
.endif
xor eax,eax
ret
WndProc endp
end start
and the batch files I posted all is fine.
If I change to coff format
jwasm -coff %1.asm
ld --format pe-i386 --subsystem windows -s -o %1.exe %1.obj -L%LIB% -lmingw32
-lmsvcrt -lkernel32 -luser32 -lgdi32 -lcomctl32 -ladvapi32 -lwinspool -lshell32 -lole32
-loleaut32 -luuid -lodbc32 -lodbccp32 -lwinmm -lcomdlg32 -limagehlp -lversion
I receive a warning: Warning: .drectve `-entry:start ' unrecognized
I am a real novice at this especially on windows as all my early jwasm testing was on Linux
James
Quote from: SteveAsm on October 27, 2011, 09:13:17 PM
Quote from: jcfuller on October 27, 2011, 07:18:13 PM
I just assumed MinGW was elf format on Windows?
These are the two batch files I am using with jwasm and MinGW.
So James,
you are using them both (Include and Lib files) right out of the box ?
Without any conversion ?
That is to say: *.h and *.a .
For use with jwasm, it appear that they would need to be converted to *.inc and *.lib.
That is the question.
Also note I am using the 32bit MinGW TDM4.6.1 not TDM64 for these tests as it's easier to use ld and I have no interest in 64bit assembler.
I do use MinGWTDM64 for all my Bcx/Ubx/C++ work.
James
jcfuller,
I thought you said "elf vs coff". You meant "omf vs coff"? Indeed omf is more compatible with mingw tools-chain, nevertheless it supports coff too.
drizz,
omf ??
As I said I'm a novice but ....
In my original bat file post I use -elf for jwasm and --format elf32-i386 for ld.
Then I tried -coff for jwasm and --format pe-i386 for ld.
Is --format pe-i386 for omf ?
If so what is coff. The information for ld is a bit confusing to me.
Thanks
James
Quote from: drizz on October 28, 2011, 01:22:33 PM
jcfuller,
I thought you said "elf vs coff". You meant "omf vs coff"? Indeed omf is more compatible with mingw tools-chain, nevertheless it supports coff too.
Ignore my last post :bdg
There are so many variations on a theme that is easy to get confused.
I don't know what input format is better for ld or if there are any issues with linking elf objects to PE.
I use -elf for linux 32, -elf64 for linux 64, -coff for win32, -win64 for win64
This is confusing and tracking down the information is just as bad!
As this is stll about the TOPIC I'll add more....
This is what I understand so far along with info on what has confused me.
MinGW gcc/g++ 32bit default is coff.
jwasm default is omf
ld appears to be able to handle a mixed bag of formats
I'm not sure on MinGW ar?
I compiled a few asm routines with jwasm xxx.asm; I assume omf xxx.obj files
I then used ar to create a static library ar rcs *.obj libmylib.a
Next I compiled asm code with jwasm using -elf and linking with ld using MinGW Windows libraries and -lmylib
All worked fine.
I wrote a simple demo on linux and japheth added this header which started the confusion on my part.
;=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
;very simple jwasm gtk example (written by jcfuller)
; create a Linux binary
; 1. assemble: jwasm -elf -zcw -Fo=gtk01.o gtk01.asm
; 2. link with LD: ld -s -o gtk01 gtk01.o -I/lib/ld-linux.so.2 `pkg-config --libs gtk+-2.0`
;
; create a Win32 binary with MinGW
; ( MinGW installed at C:\MinGW, GTK+ installed at C:\GTK )
; 1. assemble: jwasm -elf gtk01.asm
; 2. link with LD: ld -s -o gtk01.exe gtk01.obj -Lc:/gtk/lib
; -lgtk-win32-2.0.dll -lgobject-2.0.dll -Lc:/mingw/lib -lmsvcrt
;=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*=*
Time to go code some PowerBASIC and get my head straight :)
James
If it works why bother? :)
OT:
James, do you perhaps have a complete set of include files for jwasm on linux? XWindows, some kind of LinInc system or anything else like that? I would be interested in that.
drizz,
From what I remember it's a bit of this and a bit of that. I think I have a pretty complete gtk-2.
Some protos for c libraries stdio, stdlib ..... but not complete.
I ported Raymond's fpu library to linux 32bit. I really should get these a bit more organized.
James