This project is read-only.
1
Vote

P/Invoke not working

description

my code is
// helloworld.cs
using System;
using System.Runtime.InteropServices;
class X {
    [DllImport("msvcrt.dll")]
    public static extern int puts(string m);
    [DllImport("msvcrt.dll")]
    internal static extern int _flushall();
    public static void Main () 
    {
        puts("Test");
        _flushall();
    }
}
compile successfully with few minor warnings. but get linking time error:
C:\Users\INDRAJ~1\AppData\Local\Temp\cc7OtyRG.o:helloworld.cpp:(.text+0x6b): undefined reference to Int32_X_putsFSystem_StringN(System_String*)
C:\Users\INDRAJ~1\AppData\Local\Temp\cc7OtyRG.o:helloworld.cpp:(.text+0x73): undefined reference to Int32_X__flushallFN()
C:\Users\INDRAJ~1\AppData\Local\Temp\cc7OtyRG.o:helloworld.cpp:(.text.startup+0x29): undefined reference to Int32_X_putsFSystem_StringN(System_String*)
C:\Users\INDRAJ~1\AppData\Local\Temp\cc7OtyRG.o:helloworld.cpp:(.text.startup+0x2e): undefined reference to Int32_X__flushallFN()
collect2.exe: error: ld returned 1 exit status

comments