2022年11月11日 星期五

Build Eclipse 32bit C/C++ projects on a 64-bit system

 [] In eclips project explorer,Add extra "-m32" for both compiler and linker

Project->Properties --> C/C++ Build --> Settings 

-->Tool settings 

  -->gcc c compiler --> command: gcc -m32

  -->gcc c linker --> command: gcc -m32


[] extra Required Packages: add some as you need

Installing the following packages enabled standard C/C++ library calls to work. If other libraries are used within the code, additional 32-bit packages might have to be installed. Installation via Linux Mint, based on Ubuntu, is via the standard apt-get install command.

$sudo apt-get install g++-multilib lib32gcc1 libc6-i386 lib32z1 lib32stdc++6

$sudo apt-get install lib32asound2 lib32ncurses5 lib32gomp1 lib32z1-dev lib32bz2-dev

This might also be required if the code still does not compile:

$sudo apt-get install ia32-libs-gtk

After adding the suggested package libc6-dbg, the error still occurred. Installing the 32-bit version of the package fixed the error:

$sudo apt-get install libc6-dbg:i386

[]rember clean project befor first time compile new bitwidth-archecture


標籤: , , , ,

2016年10月18日 星期二

c : remove dup line

char buf[163840];
char keep_line[163840];
int _tmain(int argc, _TCHAR* argv[])
{
/*
    printf("\nargc=%d",argc);
    if(argc>1)
    {
        _tprintf(L"\nargv[1]=%s",argv[1]);
    }
    printf("\n");
*/
    keep_line[0]=0;
    char *p=NULL;
    while(1) {
        p=gets(buf);
        if(p==NULL)
            break;
        if(p!=buf) {
            printf("\n buf != p ??\n");
            break;
        }
        int len=strlen(p);
        if(len==0)
            continue;
        int diff=strcmp(p,keep_line);
        if( ! diff ) {    // dup line find
            // printf("\n--- %s",p);
            continue;
        }
       
        strcpy(keep_line,p);
        printf("\n%s ",p);
        // printf("\n%d %s",len,p);
    }
    printf("\n");
    return 0;
}

標籤: ,

2014年10月26日 星期日

windows dll share data , using pelles C 7.0R

/*
   dll file must using same folder's dll,
   X:/xx/xxx/my_dll.dll
   O:/ooo/oo/my_dll.dll
 my_dll.dll  =content=  mydll.dll
but loading to memory , it's two different dll.
*/
 
/* below is dll key function and compiler option */
/*
compiler option :  Enable microsoft extension ,   calling conv: __cdecl

*/

#pragma data_seg(".shared")
    int share_var_k = 0;
#pragma data_seg()
#pragma comment(linker, "/section:.shared,RWS")


DLLAPI int WINAPI get_share_var(void)
{   
     return share_var_k;
}

DLLAPI void WINAPI set_share_var(int value)
{   
     share_var_k = value;
}





/* ---- cut ---- */





/* -------------- below is test file function ------*/

int main(int argc, char *argv[])
{
    printf("Hello, world!\n");
    for(int i=0;i<25 br="" i="">    {
        int value=0;
        set_share_var(i);
        Sleep(1000);
        value = get_share_var();
        printf("%d\r\n",value);
    }
    return 0;

標籤: , , ,