objective-cwindowsgnustep

Can't Execute Program compiled with GNUstep


I am running Windows 10, with GNUstep. I have been trying to compile my AI.m file into a .exe so I could give it to my friend, but whenever I compile it, I get an error with the .exe file itself. I have compiled it both through the the Windows command prompt as well as the GNU Shell prompt. Either way I compile the program, it will succeed in making the file, but when I try to run it, it will launch errors. The errors it gives me are:

The procedure entry point _gxx_personality_v0 could not be located in the dynamic link library C:\GNUstep\bin\libicui18n46.dll

The procedure entry point _gxx_personality_v0 could not be located in the dynamic link library C:\GNUstep\bin\libicuuc46.dll

But if I compile the program through the GNU shell with a make file, then run the program through /obj/AI.exe while still in the GNU shell, it will load fine.

I also thought maybe it was my computer that was having an issue, so I put the .exe onto a flash drive and moved it to my laptop. When I tried to run the program on my laptop, it gave the error:

The program can't start because gnustep-base-1_24.dll is missing from your computer. Try reinstalling the program to fix this problem.

So what is causing it to only work after being done through the make file, and only via the shell following the make file? Any way to fix these errors so I can run the file?

Here is the code included in the AI.m file:

#include "stdio.h"
#include "stdlib.h"
#include "Foundation/Foundation.h"

int main(void) {

    NSAutoreleasePool *myPool = [[NSAutoreleasePool alloc] init];

    char * rawinput = malloc(sizeof(char));

    system("cls");
    fflush(stdout);

    printf("Hello, my name is (Not Yet Available), and I am an in progress AI.");
    //printf("\nCurrently, I have no features, but will be working soon.");
    //printf("\nI can't wait until I am better able to assist you.");
    fflush(stdout);

    printf("\nCurrently I can only get the date and time for you of your current location.");
    printf("\nWould like me to get one of them for you?");
    printf("\n");
    fflush(stdout);

    scanf( "%s" , rawinput );

    NSString *input = [NSString stringWithCString:rawinput encoding:1];

    if ([input caseInsensitiveCompare:@"yes"]==NSOrderedSame) {
        printf("Great! Let me pull it for you right now.");
        fflush(stdout);
        //TODO: Pull the weather
    } else if([input caseInsensitiveCompare:@"no"]==NSOrderedSame) {
        printf("I understand.  I hope I was of service to you.");
        fflush(stdout);
    } else {
        printf("Sorry, I can only understand if you say 'yes' or 'no' right now.");
        printf("\nIf you want to try again, please restart the program.");
        fflush(stdout);
    }

    [myPool drain];
    return EXIT_SUCCESS;
}

EDIT: So I went into my environmental variables for my computer, and moved the ones regarding GNUstep to the top of the list, before everything else, and now the program will open fine. So something there was causing an issue about which .dll to use from where. But how would I get this to run on another computer that doesn't have GNUstep installed on it?


Solution

  • The executable compiled with GNUstep links dynamically with some dlls. When we run the exe in GNU Shell prompt, the required dlls can be found and thus it runs correctly. But using a cmd, there's no info about those dlls.

    The solution is to copy all required dlls to the location of the exe if you want to distribute it to another computer without installing GNUstep on that computer.

    I personally found copying all dlls located in <your GUNstep installation folder>\bin and <your GUNstep installation folder>\GNUstep\System\Tools would work. In my case, it's 59 files which add up to 59.4 MB.

    And a sample dll list from a post that helped me a lot:

    -rw-rw-rw-  1 simon  staff  10101741 24 Jan 17:04 gnustep-base-1_24.dll 
    -rw-rw-rw-  1 simon  staff    118546 24 Jan 17:08 libffi-5.dll 
    -rw-rw-rw-  1 simon  staff    118784 24 Jan 17:01 libgcc_s_dw2-1.dll 
    -rw-rw-rw-  1 simon  staff   2060376 24 Jan 17:09 libgcrypt-11.dll 
    -rw-rw-rw-  1 simon  staff   3438376 24 Jan 17:09 libgnutls-26.dll 
    -rw-rw-rw-  1 simon  staff    215716 24 Jan 17:11 libgpg-error-0.dll 
    -rw-rw-rw-  1 simon  staff   1038350 24 Jan 17:09 libiconv-2.dll 
    -rw-rw-rw-  1 simon  staff  15189954 24 Jan 17:12 libicudata46.dll 
    -rw-rw-rw-  1 simon  staff   2518394 24 Jan 17:10 libicui18n46.dll 
    -rw-rw-rw-  1 simon  staff   1590522 24 Jan 17:10 libicuuc46.dll 
    -rw-rw-rw-  1 simon  staff    101390 24 Jan 17:11 libintl-8.dll 
    -rw-rw-rw-  1 simon  staff    329671 24 Jan 17:11 libp11-kit-0.dll 
    -rw-rw-rw-  1 simon  staff    978958 24 Jan 17:11 libstdc++-6.dll 
    -rw-rw-rw-  1 simon  staff   3959238 24 Jan 17:10 libxml2-2.dll 
    -rw-rw-rw-  1 simon  staff    100366 24 Jan 17:10 libz-1.dll 
    -rw-rw-rw-  1 simon  staff    659799 24 Jan 17:07 objc-4.dll 
    -rw-rw-rw-  1 simon  staff     94300 24 Jan 17:10 pthreadGC2.dll 
    
    

    Also, GNUstep seems to provide some instructions concerning making standalone packages. You can refer to the GNUstep Configuration File and Standalone packages chapters of the documentation.