5

I am on a Windows 10 machine, I have 2 files, main.cpp and cuda.cu (I have built this project on Ubuntu successfully I am trying to get it to build on Windows). I compiled both of them to make object files of 64 bit architecture. I have MS Visual Studio 2010 currently installed and I know it is too old. I can install 2015 if you think that is causing this (but I don't think so).

When I try to link the two files using the command

nvcc main.obj cuda.obj

I get this error:-

main.obj : fatal error LNK1143: invalid or corrupt file: no symbol for COMDAT section 0x6

What should I do?

dtn34-
  • 321
  • 3
  • 11
  • 3
    Compile with MSVC the object formats are tool-chain specific. `LNK1143` is from the MS linker, it can't understand the format of the obj file produced by the other tool-chain. ps why remove _"It is the main.obj (the file compiled by my g++ (MinGW_w64)) that is causing this error."_ ? – Richard Critten Jun 20 '18 at 14:51
  • @RichardCritten _why remove "It is the main.obj (the file compiled by my g++ (MinGW_w64)) that is causing this error." ?_ I didn't want to say anything myself. And thanks for replying. I will try that and report back. – dtn34- Jun 20 '18 at 14:57
  • @RichardCritten An extra question, is there any way of doing this without using MSVC? Any way of doing it just from terminals? The way it can be done from my Ubuntu? If not, then please explain why. – dtn34- Jun 20 '18 at 15:04
  • _"please explain why"_: _"object formats are tool-chain specific"_. Can it be done from Ubuntu - that should be asked in another question. – Richard Critten Jun 20 '18 at 15:25
  • 1
    well you removed the only clue to what's going on. You can't compile with MinGW and expect it to link with MSVC. They have incompatible object file formats. – rustyx Jun 20 '18 at 15:48

1 Answers1

5

As pointed out by @RichardCritten,

the files should be compiled with MSVC as the object formats are tool-chain specific. LNK1143 is from the MS linker and it can't understand the format of the obj files produced by the other tool-chain.

So object files created by MinGW's g++ can't be linked with a cuda program's object file with MSVC

dtn34-
  • 321
  • 3
  • 11