You are not logged in.
How convert Windows C++ code to Linux code?
Goodbye!
Offline
Hi,
is it plain c++ code or are there any MFC classes included or any other windows libraries?? If not, just compile it under Linux and look for errors to fix.
Another tip: Look at right typo of the includes. For windows lower cases are the same as upper cases.
Write your own makefile to manage the compilation, or use autoconf/automake to handle it.
Have fun....
Daniel
Offline
[Moved to General Programming Forum.]
Offline
Code include only:
#include <windows>
#include <string>
And 'winmm' libarary.
Thanks, but first error is: - 'error: windows.h:' - not is that file.
With what header need change 'windows.h'?
I do not know about makefiles, how need it edit...
Goodbye!
Offline
'windows.h' is the standard header for windows functions.
That doesn't exists in Linux. I don't know which functions you are calling from there....Delete the "#include <windows>"-line and look what happen next...
So there is no exact replacement for this header-file. And I don't know which functions windows.h provides. I don't use windows (neither in coding nor in daily use).
'string' exists on both, it's a standard c++ header.
How you manage makefiles and so on, look at the website of automake and autoconf: http://www.gnu.org/software/autoconf/ http://www.gnu.org/software/automake/
Offline
This is one of those things that can either be really hard or really easy. If the code in question is written in such a way that the Windows-specific bits can be easily replaced, it's a simple matter of tracking down the functions it uses and plugging in Linux functions instead. If it depends more heavily on things that Windows provides, you'll have to rewrite a substantial portion of the code to make it work.
Ise's advice is a good way to get started if you're not already familiar with the code: comment out the spots where Windows-specific headers are included then fix what breaks.
Offline
Thanks,
Maybe someone can convert this simple windows code to linux:
PlaySoundA("a.wav", NULL, SND_FILENAME | SND_ASYNC);
or this:
char b[999999];
WAVEFORMATEX wfex;HWAVEOUT hwo;
HMMIO m_hmmio; // MM I/O handle for the WAVE
MMCKINFO m_ck; // Multimedia RIFF chunk
MMCKINFO m_ckRiff; // Use in opening a WAVE file
DWORD m_dwSize=0; // The size of the wave file
WAVEHDR whdr;
HANDLE hDoneEvent = CreateEventA(NULL, FALSE, FALSE, "DONE_EVENT");
wfex.wFormatTag = WAVE_FORMAT_PCM;
wfex.nChannels = 1;
wfex.nSamplesPerSec = 22050;
wfex.nAvgBytesPerSec = 44100;
wfex.nBlockAlign = 2;
wfex.wBitsPerSample = 16;
waveOutOpen(&hwo, WAVE_MAPPER, &wfex,(DWORD) hDoneEvent, 0,CALLBACK_EVENT);
m_hmmio = mmioOpen("a.wav", NULL, MMIO_ALLOCBUF | MMIO_READ );
MMCKINFO ckIn; // chunk info. for general use.
mmioDescend( m_hmmio, &m_ckRiff, NULL, 0 );
mmioDescend( m_hmmio, &ckIn, &m_ckRiff,MMIO_FINDCHUNK );
mmioSeek( m_hmmio, m_ckRiff.dwDataOffset + sizeof(FOURCC),SEEK_SET );
m_ck.ckid = mmioFOURCC('d', 'a', 't', 'a');
mmioDescend( m_hmmio, &m_ck, &m_ckRiff,MMIO_FINDCHUNK );// )
m_dwSize =m_ck.cksize;
MMIOINFO mmioinfoIn; // current status of m_hmmio
mmioGetInfo( m_hmmio, &mmioinfoIn, 0 );
for(DWORD cT=0;cT<m_dwSize;cT++) {
if(mmioinfoIn.pchNext==mmioinfoIn.pchEndRead) {
mmioAdvance( m_hmmio, &mmioinfoIn, MMIO_READ );
}
*((BYTE*)b+cT)=*((BYTE*)mmioinfoIn.pchNext);
mmioinfoIn.pchNext++;
}
mmioClose(m_hmmio,0);
ZeroMemory(&whdr, sizeof(WAVEHDR));
whdr.lpData=b;
whdr.dwBufferLength =m_dwSize;
waveOutPrepareHeader(hwo, &whdr, sizeof(WAVEHDR));
waveOutWrite(hwo, &whdr, sizeof(WAVEHDR));
while (!(whdr.dwFlags & WHDR_DONE)) {
WaitForSingleObject(hDoneEvent, INFINITE);
}
waveOutUnprepareHeader(hwo, &whdr, sizeof(WAVEHDR));
waveOutClose(hwo);
But I use Quincy (http://codecutter.net/tools/quincy/)with Wine and creating that .exe files.
Quincy not create 'makefile' (I not understand why me need 'makefile' edit and from were I can get it?) files, it create 'filename.o' files only.
And I understoond, then read Wine text, that with Wine (http://www.winehq.com/) possible convert Windows code to Linux, but do not known how.
How convert Windows code to Linux with Wine?
Goodbye!
Offline
Not use "#include <windows>" and look what happen next with file that use only this lines:
int WINAPI WinMain (HINSTANCE hThisInstance,
HINSTANCE hPrevInstance,
LPSTR lpszArgument,
int nFunsterStil)
{
PlaySoundA("a.wav", NULL, SND_FILENAME | SND_ASYNC);
return 0;
}
:[al@myhost kalba]$ g++ ./playsound.cpp
./playsound.cpp:1: error: expected initializer before 'WinMain'
Goodbye!
Offline
Well, no wonder. All of these macros are Windows specific. It seems that this code is simply not portable, so your best chance would be using winelib.
I've never used winelib myself, but I'm sure google would prove useful.
Some PKGBUILDs: http://members.lycos.co.uk/sweiss3
Offline
Check out the source for aplay to see how to do sound playback in a linux environment.
Offline
Thanks, but were I can check out the source for aplay to see how to do sound playback in a linux environment?
Goodbye!
Offline
aplay belongs to the alsa-utils package. The sources are:
ftp://ftp.alsa-project.org/pub/utils/al … 11.tar.bz2
Offline
You should be able to compile Windows API code with libwine. Install wine, add the right include path and try it.
Offline
I have instaled wine with 'pacman -S wine'.
How add right include patch? I not understood.
Thanks!
I check 'aplay.c' in yuo package and it very big file and I can not it compile, maybe somebody can write short complitely code how play WAVE file with Linux.
Goodbye!
Offline