请问小弟我如果想创建一个C++工程,使在windows和linux unix上都可以编译怎么处理?另外linux如何连数据库呀

请教我如果想创建一个C++工程,使在windows和linux unix上都可以编译怎么办?另外linux怎么连数据库呀?
请教我如果想创建一个C++工程,,使在windows和linux   unix上都可以编译怎么办?另外linux怎么用C++连Oracle数据库呀?

------解决方案--------------------
通用编译方法如下:


// 均支持的 include
#include <stdio.h>
#include <stdarg.h>
#include <sys/stat.h>

#include <fstream>
#include <time.h>
#ifdef agent_windows
#define PATH_CONFIG "..\\cfg\\ "
#define PATH_RUNLOG "..\\log\\ "
#define PATH_STTCDATA "..\\sdata\\ "
#else
#define PATH_CONFIG "../cfg/ "
#define PATH_RUNLOG "../log/ "
#define PATH_STTCDATA "../sdata/ "
#endif //agent_windows

// 有差异的 include
#ifdef agent_windows

typedef enum log_level_t {
CR = 0,
ER,
WA,
TR,
ST
} log_level_t;

#define WIN32_LEAN_AND_MEAN // Exclude rarely-used stuff from Windows headers
#define _WIN32_WINNT 0x0400

#include <windows.h>
#include <sstream>
#include <conio.h>
#include <tchar.h>
#include <pdh.h>


#define SokErrorNo h_errno

#define MUTEX_LOCK CRITICAL_SECTION
#define MUTEX_LOCK_INIT(lock) InitializeCriticalSection(lock)
#define MUTEX_LOCK_DESTROY(lock) DeleteCriticalSection(lock)
#define LOCK EnterCriticalSection
#define UNLOCK LeaveCriticalSection
#define TRYLOCK TryEnterCriticalSection
#define SLEEP(nMill) Sleep(nMill);
#define MSLEEP(nMill) Sleep(nMill);
#define SLASHC '\\ '
#define SLASHSTR "\\ "

typedef struct _stat sSTAT;
#define STAT _stat

#include "winsock2.h "
#pragma comment(lib, "ws2_32.lib ")

#else

#ifndef _UNIX_
#define _UNIX_
#endif

typedef int BOOL;

#ifndef FALSE
#define FALSE 0
#endif

#ifndef TRUE
#define TRUE 1
#endif


typedef unsigned int UINT;

typedef unsigned long DWORD;
typedef void* HANDLE;
typedef void* LPVOID;
typedef const char *LPCSTR, *PCSTR;
typedef LPCSTR LPCTSTR;

typedef unsigned int SOCKET;

#include <sys/types.h>
#include <sys/ipc.h>
//#include <sys/ddi.h>
#include <sys/msg.h>
#include <unistd.h>
#include <errno.h>
#include <pthread.h>
#include <string>
#include <iostream>
#include <arpa/inet.h>
#include <semaphore.h>
#include <sys/socket.h>
#include <signal.h>
#include "ConfigFile.h "

#include <applib.h>
#include <bsclib.h>


#define INVALID_SOCKET (SOCKET)(~0)
#define SOCKET_ERROR (-1)
#define closesocket close
#define SokErrorNo errno

#define MUTEX_LOCK pthread_mutex_t
#define MUTEX_LOCK_INIT(lock) pthread_mutex_init(lock,NULL)
#define MUTEX_LOCK_DESTROY(lock) pthread_mutex_destroy(lock)
#define LOCK pthread_mutex_lock
#define UNLOCK pthread_mutex_unlock
#define TRYLOCK(lock) (pthread_mutex_trylock(lock) == 0)
#define SLEEP(nMill) sleep((int)nMill/1000);
#define MSLEEP(nMill) usleep(nMill*1000);
#define SLASHC '/ '
#define SLASHSTR "/ "

typedef struct stat sSTAT;
#define STAT stat
#endif //agent_windows