Tags down


How to compile C ++ code from Windows for Linux (Dev-Cpp)

By : Venkatesh
Date : July 31 2020, 12:00 PM
Does that help You can install Windows Subsystem for Linux, or set up a VM and do it that way.
Or as @user4581301 mentioned, use a cross-compiler.
code :

Share : facebook icon twitter icon

How to compile a C++ source code written for Linux/Unix on Windows Vista (code given)

By : user1912806
Date : March 29 2020, 07:55 AM
hop of those help? Here we go, you've just got good compiler. mingw32-gcc compiler (which is DevCpp built-in compiler) just giving some error like this
code :
error: dependent-name ` T::int' is parsed as a non-type, but instantiation yields a type
 PrefixSpan: An efficient algorithm for sequential pattern mining

 $Id: prefixspan.cpp,v 1.8 2002/04/03 13:35:23 taku-ku Exp $;

 Copyright (C) 2002 Taku Kudo   All rights reserved.
 This is free software with ABSOLUTELY NO WARRANTY.

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; either version 2 of the License, or
 (at your option) any later version.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
 02111-1307, USA

#include <iostream>
#include <map>
#include <vector>
#include <string>
#include <string.h>
#include <strstream>
#include <unistd.h>
#include <stdlib.h>

using namespace std;

template <class T> class PrefixSpan {
    vector < vector <T> >            transaction;
    vector < pair <T, unsigned int> > pattern;
    unsigned int minsup;
    unsigned int minpat;
    unsigned int maxpat;
    bool all;
    bool where;
    string delimiter;
    bool verbose;
    ostream *os;

void report (vector <pair <unsigned int, int> > &projected){
    if (minpat > pattern.size()) return;

    // print where & pattern
    if (where) {
        *os << "<pattern>" << endl;

        // what:
        if (all) {
            *os << "<freq>" << pattern[pattern.size()-1].second << "</freq>" << endl;
            *os << "<what>";
            for (unsigned int i = 0; i < pattern.size(); i++)
                *os << (i ? " " : "") << pattern[i].first;
            } else {
                *os << "<what>";
                 for (unsigned int i = 0; i < pattern.size(); i++)
                    *os << (i ? " " : "") << pattern[i].first << delimiter << pattern[i].second;
            *os << "</what>" << endl;

        // where
        *os << "<where>";
        for (unsigned int i = 0; i < projected.size(); i++)
            *os << (i ? " " : "") << projected[i].first;
        *os << "</where>" << endl;
        *os << "</pattern>" << endl;
    } else {
        // print found pattern only
        if (all) {
             *os << pattern[pattern.size()-1].second;
             for (unsigned int i = 0; i < pattern.size(); i++)
                *os << " " << pattern[i].first;
            } else {
                 for (unsigned int i = 0; i < pattern.size(); i++)
                    *os << (i ? " " : "") << pattern[i].first << delimiter << pattern[i].second;

        *os << endl;

void project (vector <pair <unsigned int, int> > &projected){
    if (all) report(projected);

    map <T, vector <pair <unsigned int, int> > > counter;

    for (unsigned int i = 0; i < projected.size(); i++) {
        int pos = projected[i].second;
        unsigned int id = projected[i].first;
        unsigned int size = transaction[id].size();
        map <T, int> tmp;
        for (unsigned int j = pos + 1; j < size; j++) {
            T item = transaction[id][j];
            if (tmp.find (item) == tmp.end()) tmp[item] = j ;

        for (typename map <T, int>::iterator k = tmp.begin(); k != tmp.end(); ++k)
            counter[k->first].push_back (make_pair <unsigned int, int> (id, k->second));

    for (typename map <T, vector <pair <unsigned int, int> > >::iterator l = counter.begin ();
    l != counter.end (); ) {
        if (l->second.size() < minsup) {
            typename map <T, vector <pair <unsigned int, int> > >::iterator tmp = l;
            tmp = l;
            counter.erase (l);
            l = tmp;
        } else {

    if (! all && counter.size () == 0) {
        report (projected);

    for (typename map <T, vector <pair <unsigned int, int> > >::iterator l = counter.begin ();
    l != counter.end(); ++l) {
        if (pattern.size () < maxpat) {
             pattern.push_back (make_pair <T, unsigned int> (l->first, l->second.size()));
             project (l->second);
             pattern.erase (pattern.end());

    PrefixSpan (unsigned int _minsup = 1,
            unsigned int _minpat = 1,
            unsigned int _maxpat = 0xffffffff,
            bool _all = false,
            bool _where = false,
            string _delimiter = "/",
            bool _verbose = false):
    minsup(_minsup), minpat (_minpat), maxpat (_maxpat), all(_all),
    where(_where), delimiter (_delimiter),  verbose (_verbose) {};

    ~PrefixSpan () {};

    istream& read (istream &is){
        string line;
        vector <T> tmp;
        T item;
        while (getline (is, line)) {
            tmp.clear ();
            istrstream istrs ((char *)line.c_str());
            while (istrs >> item) tmp.push_back (item);
            transaction.push_back (tmp);

        return is;

    ostream& run (ostream &_os){
        os = &_os;
        if (verbose) *os << transaction.size() << endl;
        vector <pair <unsigned int, int> > root;
        for (unsigned int i = 0; i < transaction.size(); i++)
            root.push_back (make_pair (i, -1));
         project (root);
        return *os;

    void clear (){
        transaction.clear ();
        pattern.clear ();

int main (int argc, char **argv){
    extern char *optarg;
    unsigned int minsup = 1;
    unsigned int minpat = 1;
    unsigned int maxpat = 0xffffffff;
    bool all = false;
    bool where = false;
    string delimiter = "/";
    bool verbose = false;
    string type = "string";

    int opt;
    while ((opt = getopt(argc, argv, "awvt:M:m:L:d:")) != -1){
        switch(opt) {
        case 'a':
            all = true;
        case 'w':
            where = true;
        case 'v':
            verbose = true;
        case 'm':
            minsup = atoi (optarg);
        case 'M':
            minpat = atoi (optarg);
        case 'L':
            maxpat = atoi (optarg);
        case 't':
            type = string (optarg);
        case 'd':
            delimiter = string (optarg);
            cout << "Usage: " << argv[0]
            << " [-m minsup] [-M minpat] [-L maxpat] [-a] [-w] [-v] [-t type] [-d delimiter] < data .." << endl;
            return -1;

    if (type == "int") {
         PrefixSpan<unsigned int> prefixspan (minsup, minpat, maxpat, all, where, delimiter, verbose);
         prefixspan.read (cin);
         prefixspan.run (cout);
    }else if (type == "short") {
         PrefixSpan<unsigned short> prefixspan (minsup, minpat, maxpat, all, where, delimiter, verbose);
         prefixspan.read (cin);
         prefixspan.run (cout);
    } else if (type == "char") {
         PrefixSpan<unsigned char> prefixspan (minsup, minpat, maxpat, all, where, delimiter, verbose);
         prefixspan.read (cin);
         prefixspan.run (cout);
    } else if (type == "string") {
         PrefixSpan<string> prefixspan (minsup, minpat, maxpat, all, where, delimiter, verbose);
         prefixspan.read (cin);
         prefixspan.run (cout);
    } else {
        cerr << "Unknown Item Type: " << type << " : choose from [string|int|short|char]" << endl;
        return -1;

    return 0;

Can i compile any c code writen for linux, on windows?

By : user3478396
Date : March 29 2020, 07:55 AM
hop of those help?
see if i have made one c program in c on linux machine now if i want to compile that program on other os or lets say on windows how can i do that.?

Compile C++ code under windows for linux, as ready to run

By : Ralph
Date : March 29 2020, 07:55 AM
Any of those help Assuming you want to be able to compile something on Windows and have it work on any Linux machine, that's simply not possible. Debian and Ubuntu both support many architectures, many of which have absolutely no binary compatibility. If you know what type of hardware your friend has you can build a binary targeted to that architecture.
If you want a quick and dirty answer, you can build for i386 since a 64bit machine can probably still run it fine (not guaranteed though).

How to compile C code in Linux to run on Windows?

By : Raphaeldcosta08
Date : March 29 2020, 07:55 AM
help you fix your problem You would need a cross-compiler to create a Windows executable in Linux.
Mingw-w64 is an advancement of the original mingw.org project, created to support the GCC compiler on Windows systems.
code :
sudo apt-get install mingw-w64
i686-w64-mingw32-gcc -o test.exe test.c
x86_64-w64-mingw32-gcc -o test.exe test.c

Can one compile Windows code on Linux?

By : Ahmd Aleame
Date : March 29 2020, 07:55 AM
this one helps. Using VC++ directly on Linux is not possible. To let the Linux server do the compiling with VC++ anyway you could either use wine which apparently works with older Versions (see https://appdb.winehq.org/objectManager.php?sClass=application&iId=5766 ) but propably is not easy to set up in a CLI envrioment and might cause License Issues with Microsoft, or use Windows Virtual Machines, which tend to have some Performance drawback.
The best Solution would be to use GCC (g++), which works on a wide range of architectures and operating systems and supports cross compiling.
Related Posts Related Posts :
  • C++: std::vector - std::find & std::distance query
  • Is this a safe way to start and stop a thread?
  • Maximum Pair Product strange results
  • Why does gcc produce this weird assembly vs clang?
  • What it does when we write for(;;) ? What does the double semicolon in the for loop does?
  • "Inverse SFINAE" to avoid ambiguous overload
  • Reuse an operator<< for several classes
  • Safe to std:move a member?
  • Don't understand iterator, reference and pointer invalidation, an example
  • Why don't we just keep all dynamic memory in arrays?
  • Istream function to read with istream parameter
  • What is the best method to sort a dynamic array of c-strings in a class in c++?
  • Passing an additional parameter to a function called using beast::bind_front_handler
  • A compiler's evaluation of the size of an array's declaration. When does it take place?
  • Why am I getting a segmention fault?
  • Deprecation of _writeBarrier()
  • C++ How to make a std::list of arrays?
  • List of multiple class to run same function name C++
  • Overloading a function using templates
  • how to print boost multiprecision 128 bit unsigned integer
  • Alternatives to std::array for objects of different types in C++11
  • Default Argument for Function Template not working
  • thread safe with pop and visit in c++ queue
  • How to prevent a base class from inheritance in C++?
  • How to keep track of QLabel created in a loop using new operator
  • std::find_if gives "conditional expression of type 'void' is illegal" error
  • Why does not my code in C++ that declares an (local) int array without doing anything initialize by zeros?
  • How to calculate average asymptotic running time in Big-O notation?
  • I have a vector that has pointers to elements from 2 subtypes accessed via an interface. Can't seem to re-arrange the ve
  • Let a function accept different types for the same variable?
  • Returning back to main function from c or cpp series of sub functions
  • What is the rationale behind the `std::unique_XXX` naming convention?
  • What does a returned link to a C ++ object look like
  • How to break an arduino uno memory with a vector?
  • how to get values to update in c++
  • Init once with lambda function pointer, self-modifying (C++)
  • Get Latin Character in C++
  • weak_ptr, shared_ptr in lambda capture list and std::queue<T,Container>::emplace
  • Purpose of function prototypes
  • Memory allocation for objects in arrays
  • Building a library consisting of C and C++ files
  • Why isn't my variable being updated and my LEDs don't go on?
  • Says it cannot be used as constant
  • How to make word triangle in c++ with for loop
  • Find substring in string from the end
  • Get max of 2 objects
  • C++ Program skipping second fuction call
  • How do i use MMX mulH and mulL for two 64 bit integers to get one 128 bit integer
  • c++ fold expression with user defined class
  • Two sets of curly braces using lambda functions?
  • IsDigit() in c reading char as digit in C
  • How shared_ptr detects if it has to call delete[] or delete
  • Why the loop becomes infinite?
  • Is it possible to define a 'move-and-swap idiom' equivalent in C++03
  • How to set all the bits in a char array to zeros?
  • Why register storage class is explicitly deprecated
  • Not getting the expected output in strings
  • How do I look for a byte sequence in a file?
  • Iterate through template parameter
  • Is it possible to make shared_ptr covariant?
  • shadow
    Privacy Policy - Terms - Contact Us © voile276.org