The MASM Forum Archive 2004 to 2012

General Forums => The Campus => Topic started by: LithiumDex on January 17, 2007, 01:06:30 AM

Title: TinyPTC -> MASM32 (Linking problems)
Post by: LithiumDex on January 17, 2007, 01:06:30 AM
I'm attempting to create a (conceptual) system for using TinyPTC with MASM32..
Those who aren't fermilure with TinyPTC and how it works, it's basically a simple graphics library, which gives you the ability to create a window/go into full screen and write a buffer too that surface. There are only three functions, and the options (i.e. fullscreen vs windowed) are set with macros in the tinyptc.h file, and the options are "hardcoded" in when it is compiled.

Now, the windows version comes with uncompiled C source, and ASM (NASM) source, with a VC 6.0 project workspace file...

So anyway, what I'm trying to do is this:
- Compile the source in VC 2003 (works)
- Take the object files (exluding the demo or main module) and use masm32\bin\lib.exe to make them into a library
- Create a simple header file and example program with MASM32

I'm learning a lot of this as I go along, but it's getting there -- I have all 3 of the above "done", i'm just having this problem:

Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

Assembling: D:\asmcast\asmcast.asm
Microsoft (R) Incremental Linker Version 5.12.8078
Copyright (C) Microsoft Corp 1992-1998. All rights reserved.

asmcast.obj : error LNK2001: unresolved external symbol _ptc_open@12
asmcast.obj : error LNK2001: unresolved external symbol _ptc_update@4
asmcast.obj : error LNK2001: unresolved external symbol _ptc_close@0
asmcast.exe : fatal error LNK1120: 3 unresolved externals
_
Link error


I don't really understand why, given the set of macro settings for this build, and the fact that the demo works, the functions are definatley there... The only thing I can think of is that maybe VC 2003 has some weird way of naming functions it compiles. But anyway, I've uploaded both sources: http://lithium.zext.net/Tiny-PTC.rar (converted to 2003 source), and my MASM32 test: http://lithium.zext.net/asmcast.rar

Any help would be greatly appretiated.
Title: Re: TinyPTC -> MASM32 (Linking problems)
Post by: hutch-- on January 17, 2007, 02:52:33 AM
Two things, make sure you have prototyped the functions correctly and make sure the functions are available in the library or source code. Usually an unresolved external problem breaks down to one of these.
Title: Re: TinyPTC -> MASM32 (Linking problems)
Post by: LithiumDex on January 17, 2007, 03:35:53 AM
fixed those by adding _stdcall too the prototypes in the c source, but now I'm getting:
LINK : fatal error LNK1104: cannot open file "uuid.lib"

uuid.lib is in masm32\lib -- what does this mean?
Title: Re: TinyPTC -> MASM32 (Linking problems)
Post by: LithiumDex on January 17, 2007, 04:59:41 AM
(http://lithium.zext.net/tinyptc.png)

woo!

I had link them as obj files... which isn't quite what I wanted, a .lib would mean I could build it from the qeditor... That's allright though -- My only other quarrel is the size of the executable... It's f'ing huge for tinyPTC and asm.. I'm wondering if that's because it uses DirectX?

Anyway, thanks for your help hutch, I think I'm going to write a raycasting engine.

http://lithium.zext.net/asmcast.rar (working demo as seen above)
Title: Re: TinyPTC -> MASM32 (Linking problems)
Post by: Tedd on January 17, 2007, 01:45:34 PM
The large size probably comes from the fact that you're linking the obj, which basically means you have your program with the whole ptc library stuck to it (whether or not you even use half of it.)
If you can manage to build TinyPTC as a set of lib files (might take a bit more work), then only the functions you use/need will be included, so the size should come down a lot.
Title: Re: TinyPTC -> MASM32 (Linking problems)
Post by: LithiumDex on January 17, 2007, 06:32:18 PM
right... I think I could get it to work, but I do remeber having to pull "oldnames.lib" out of my msvs\lib folder for it too compile, maybe that's not such a big deal.

EDIT: Also I'm hoping that it doesn't have .net dependanceys... is so maybe I should get myself a copy of VC 6

EDIT: TinyPtc obj files -> 16kb, VC 8 demo exe size -> ~20kb, my executable -> 300kb :/
Title: Re: TinyPTC -> MASM32 (Linking problems)
Post by: LithiumDex on January 17, 2007, 11:52:05 PM
It was just because I had defined the frame buffer in exe space, using malloc put the exe size down to 6kb. Works using a lib now, and I modified the original to include a deinit "callback", so you can free up any memory before TinyPTC calls ExitProcess.

If anyone wants to use this I can clean it up and upload it, just post.