flat assembler
Message board for the users of flat assembler.
  
|  Index
      > Main > Combining gcc generated .obj with FASM generated .obj | 
| Author | 
 | 
| revolution 07 Dec 2013, 18:13 At a minimum you will have to define strToInt, printf and ExitProcess using extrn. | |||
|  07 Dec 2013, 18:13 | 
 | 
| kamac 07 Dec 2013, 18:19 But it's there already.
 Code: extrn '__imp__printf' as printf:DWORD extrn '__imp__ExitProcess@4' as ExitProcess:DWORD extrn strToInt From what I read, it could be due to mixing of SJLJ and DW2.. But that's all I know. | |||
|  07 Dec 2013, 18:19 | 
 | 
| eax 07 Dec 2013, 19:04 great question, i was wondering about foreign functions with FASM myself. | |||
|  07 Dec 2013, 19:04 | 
 | 
| dancho 08 Dec 2013, 19:55 how to mix C++(VS) and fasm(obj) :
 1.) in VS create new console project 2.) copy this code Code: #include <iostream> #include <conio.h> using namespace std; // proto for the extern func extern "C" unsigned int AddFunc(unsigned int x, unsigned int y); int main(void) { cout << "10 + 20 = " << AddFunc(10,20) << endl; _getch(); return 0; } 3.) open fasmw copy and save as AddFunc.asm , compile it Code: format MS COFF include 'win32axp.inc' public AddFunc as '_AddFunc' section '.code' code readable executable proc AddFunc c p1,p2 mov eax,[p1] add eax,[p2] ret endp section '.data' data readable writeable nop 4.) copy AddFunc.obj into main VS directory 5.) open project properties and under linker there is an input item, subitem additional dependencies , write AddFunc.obj here 6.) compile and run | |||
|  08 Dec 2013, 19:55 | 
 | 
| kamac 09 Dec 2013, 16:16 Though, I needed it the other way around   (combine c/c++ .obj files with ASM's .obj files and thus link them together with something like ld) | |||
|  09 Dec 2013, 16:16 | 
 | 
| cod3b453 09 Dec 2013, 18:06 Given that this is C++ you need the proper compiler "hash".
 Comment out the C++ code, declare as extern and make a call to it in C++: Code: extern const char* strToInt(int i); //{ // return NULL; //(void)i; //} // ... strToInt(0); Code: Error 1 error LNK2001: unresolved external symbol "char const * __cdecl strToInt(int)" (?strToInt@@YAPEBDH@Z) main.obj 1 1 aluminium Code: extrn '?strToInt@@YAPEBDH@Z' as strToInt:DWORD | |||
|  09 Dec 2013, 18:06 | 
 | 
| dancho 09 Dec 2013, 18:28 kamac wrote: Though, I needed it the other way around ahh yes , sry , just ignore my post then... | |||
|  09 Dec 2013, 18:28 | 
 | 
| < Last Thread | Next Thread > | 
| Forum Rules: 
 | 
Copyright © 1999-2025, Tomasz Grysztar. Also on GitHub, YouTube.
Website powered by rwasa.