linking trouble

rikki cattermole rikki at cattermole.co.nz
Thu Sep 6 16:59:43 UTC 2018


On 07/09/2018 4:03 AM, hridyansh thakur wrote:
> i am on windows i have tried
> DMD
> LDC
> 
> and i am getting same linking error with linking my c++ object
> 
> i am doing by the official tutorial (dlang spec book)
> 
> here is my app.d code
> 
> import std.stdio;
> 
> void main()
> {
>      //writeln("Edit source/app.d to start your project.");
>      int[] m = someFUN(44,55);
>      ulong k = m.length;
> 
>      for (int i=0;i<k;i++)
>      writeln(m[i]);
> 
> 
> }
> 
> auto someFUN(int j , int k){
>      int[] some = new int[j];
> 
>      for (int i =0 ; i<j ; i++)
>          some[i] =  i;
> 
>          return some ;
> }
> 
> extern(C++){int*file_io}

That definition isn't complete. Missing at the very least ``();`` to 
make it a function declaration.

> here is the C++ code
> 
> #include <iostream>
> #include <stdio.h>
> #include <stdlib.h>
> 
> FILE *fp;
> 
> int*file_io(){
> 
> char name[20] ;
> 
> std::cout << "please enter the file name " << '\n';
> std::cin >> name;
> 
>    fp = fopen(name,"r+");
>   char  a  = 'a';
>    int  n  =  0 ;
>    while (!feof(fp)) {
>      a = fgetc(fp);
>      if (a=='\n') {
>        n++;
>      }
>    }
> 
>   int *p  = (int*)calloc(n,sizeof(int));
>   for (size_t i = 0; i < n ; i++) {
>     fscanf(fp,"%d",(p+i));
>   }
> 
> return p;
> 
> }

So what is the errors you're getting?
And what are the commands you're executing?



More information about the Digitalmars-d-learn mailing list