Author Topic: Adding an external OBJ file to be linked into a static library project  (Read 4834 times)

Offline mrmoelgaard

  • Single posting newcomer
  • *
  • Posts: 6
    • Kamstrup A/S
Hello,

I'm working on a project that among many dependencies use a small piece of assembly code compiled into an OBJ file. From what I can see when trying to disassemble the file it seems to be written in A86 with Turbo Assembler 4.1 compatibility.

My target platform is DOS 6.22 and I'm using the Open Watcom compiler configured to 16 bit DOS.

I would like some hints to how/where I specify that this external OBJ file should be linked with the OBJ files compiled in the project. This might be a compiler/linker related question.

I've tried to put the file in the "Other linker options" under project build options, but this doesn't seem to be the right way.

Hopefully someone out there/in here are able to give me some advice.

Thanks in advance.
Emil

Offline MortenMacFly

  • Administrator
  • Lives here!
  • *****
  • Posts: 9723
Re: Adding an external OBJ file to be linked into a static library project
« Reply #1 on: January 22, 2016, 02:11:04 pm »
I've tried to put the file in the "Other linker options" under project build options, but this doesn't seem to be the right way.
Other linker options should be fine. How did you do that?

You could also add the object file to your project and untick "compile file" in the file's properties and tick "link file" only.
Compiler logging: Settings->Compiler & Debugger->tab "Other"->Compiler logging="Full command line"
C::B Manual: https://www.codeblocks.org/docs/main_codeblocks_en.html
C::B FAQ: https://wiki.codeblocks.org/index.php?title=FAQ

Offline mrmoelgaard

  • Single posting newcomer
  • *
  • Posts: 6
    • Kamstrup A/S
Re: Adding an external OBJ file to be linked into a static library project
« Reply #2 on: January 22, 2016, 03:05:49 pm »
Well, by default $link_options isn't added to the "Link object files to static library" command under advanced options on the OpenWatcom compiler settings. I guess that's required to get c::b to include the "Other linker options" in the link command arguments?
(By the way, it's a bit challenging that the listed command macros in "Advanced compiler options" are different than what you have to enter. In 15.12 RC1 you see Linker flags specified as "$$linkeroptions" but you have to enter "$linker_options". All the command macros in 15.12 seems to have an extra '$' prepended compared to 13.12. But 13.12 also suffers from the missing underscore in the macros. Oh well...)

Back on track. If I add $linker_options I get a "debug all" part added to the linker arguments which is not understood by the OpenWatcom library linker wlib. I cannot see what causes the "debug all" to be added, so for now it's a dead end.

I've tried to add the obj file to the project. It might be the way to go, but I have to place the file twice in the source tree (or setup a prebuild copy job) since the "Objects output dir" is prepended to all obj files including the one I add. So if I add the file in the root of my source tree I get an error because the file wasn't found in obj\Debug\extasm.obj. If I place the file in obj\Debug\ and add it to the project on that location I get an error because the file wasn't found in obj\Debug\obj\Debug\extasm.obj.

However I still get an undefined reference on the methods I try to call from the external obj. It works in the M$ VC++ environment I'm trying to escape from, so the're must be a way. I think I'll try to get it working in the OpenWatcom IDE and see if I can transfer the setup to c::b afterwards.

Thanks for your input. Highly appreciated!

Best regards
Emil