Compiling C++ program on the Windows

Hi
I want to compile the following program on Windows but I am unable compile this program on windows it compiles fine on Ubuntu however I need to simulate this test case on windows based machines.
https://github.com/Haivision/srt

I have tried to compile for windows on ubuntu however the configure file doesn't have the extension and it doesn't work.
all I want to do is compile this for windows whether from ubuntu or via visual studio.
LVL 11
mattibuttAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Martin MillerCTOCommented:
Hi,

Did you follow the instructions in the Mark Down document ?  Readme.md

I am reposting the steps here:
Please download and install OpenSSL for Windows.
The 64-bit devel package can be downloaded from here:

 http://slproweb.com/download/Win64OpenSSL-1_0_2a.exe
(Note that the last letter or version number may be changed and older versions no longer available. If this isn't found, check here: http://slproweb.com/products/Win32OpenSSL.html )

It's expected to be installed in C:\OpenSSL-Win64 (see the above variables).

Note that this version is compiled most likely for Visual Studio 2013. For other versions you better download and compile the sources by yourself, from: https://github.com/openssl/openssl

The instruction for Windows: http://developer.covenanteyes.com/building-openssl-for-visual-studio/

Compile and install Pthreads for Windows from this submodule:

submodules/pthread-win32

Please follow the steps:

a. Using Visual Studio 2013, please open this file:

 pthread_lib.2013.vcxproj
b. Make sure to select configuration: Release and x64.

c. Make sure that the pthread_lib project will be built.

d. After building, find the pthread_lib.lib file (directory is probably: bin\x64_MSVC2013.Release). Copy this file to C:\pthread-win32\lib (or whatever other location you configured in variables).

e. Copy include files to C:\pthread-win32\include - the following ones:

 pthread.h
 sched.h
 semaphore.h
(They are in the toplevel directory, there are actually no meaningful subdirs here) (NOTE: the win32 is part of the project name. It will become 32 or 64 depending on selection)

Install cmake for Windows. The CMake GUI will help you configure the project.
It will try to find OpenSSL and pthreads. If you installed them in the default location, they will be found automatically. If not, you can define the following variables to help CMake find them:

OPENSSL_ROOT_DIR=<path to OpenSSL instalation>
OPENSSL_LIBRARIES=<path to all the openssl libraries to link>
OPENSSL_INCLUDE_DIR=<path to the OpenSSL include dir>

PTHREAD_INCLUDE_DIR=<path to where pthread.h lies>
PTHREAD_LIBRARY=<path to pthread.lib>
For the sake of cmake generation: When you want to have a 64-bit version, remember that cmake by some reason adds /machine:X86 to the linker options. There are about four variables ended with _LINKER_FLAGS in the CMakeCache.txt file (also available with Advanced checked in CMake GUI). Remove them, or change into /machine:X64.
Also, just after you generated the project for MSVC (if you fail or forget to do that before the first compiling, you'll have to delete and regenerate all project files) then open Configuration Manager exactly after generation from cmake and setup x86 platform with requesting to generate this for every subproject.

IMPORTANT FOR DEVELOPERS AND CONTRIBUTORS: If you make any changes that fix something in the Windows version, remember to keep the project working also for all other platforms. To simplify the verification if you just would like to do it on the Windows machine, please install Cygwin and make another build for Cygwin, for example (remember that 'configure' script requires tcl8.5 package):

 mkdir build-cygwin
 cd build-cygwin
 ../configure --prefix=install --cygwin-use-posix
 make
The Cygwin platform isn't any important target platform for this project, but it's very useful to check if the project wouldn't be build-broken on Linux.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
sarabandeCommented:
in the link you have given there was a detailed instruction how to get it compiled with visual studio (see below extract). you may download visual studio community 2017 (instead of VS2013) for free. after setup of visual studio first try to build the OpenSSL you downlaoded from the given link. ask a new question if that difn't work. if openssl libraries are successfully built try to open the project file pthread_lib.2013.vcxproj. i would copy it before to pthread.vxproj and open the copied project file. VS then should offer to convert the project file to VS2017 what you should do. if the pthread project doesn't build (and errors can't be solved) you could try to run VS2017 but compile and link using VS2013.

Sara

Extract from instructions to build the SRT project

For Windows:

Please download and install OpenSSL for Windows.

The 64-bit devel package can be downloaded from here:

 http://slproweb.com/download/Win64OpenSSL-1_0_2a.exe

(Note that the last letter or version number may be changed and older versions no longer available. If this isn't found, check here: http://slproweb.com/products/Win32OpenSSL.html )

It's expected to be installed in C:\OpenSSL-Win64 (see the above variables).

Note that this version is compiled most likely for Visual Studio 2013. For other versions you better download and compile the sources by yourself, from: https://github.com/openssl/openssl

The instruction for Windows: http://developer.covenanteyes.com/building-openssl-for-visual-studio/

    Compile and install Pthreads for Windows from this submodule:

    submodules/pthread-win32

Please follow the steps:

a. Using Visual Studio 2013, please open this file:

 pthread_lib.2013.vcxproj

b. Make sure to select configuration: Release and x64.

c. Make sure that the pthread_lib project will be built.

d. After building, find the pthread_lib.lib file (directory is probably: bin\x64_MSVC2013.Release). Copy this file to C:\pthread-win32\lib (or whatever other location you configured in variables).

e. Copy include files to C:\pthread-win32\include - the following ones:

 pthread.h
 sched.h
 semaphore.h

(They are in the toplevel directory, there are actually no meaningful subdirs here) (NOTE: the win32 is part of the project name. It will become 32 or 64 depending on selection)

    Install cmake for Windows. The CMake GUI will help you configure the project.

It will try to find OpenSSL and pthreads. If you installed them in the default location, they will be found automatically. If not, you can define the following variables to help CMake find them:

OPENSSL_ROOT_DIR=<path to OpenSSL instalation>
OPENSSL_LIBRARIES=<path to all the openssl libraries to link>
OPENSSL_INCLUDE_DIR=<path to the OpenSSL include dir>

PTHREAD_INCLUDE_DIR=<path to where pthread.h lies>
PTHREAD_LIBRARY=<path to pthread.lib>

    For the sake of cmake generation: When you want to have a 64-bit version, remember that cmake by some reason adds /machine:X86 to the linker options. There are about four variables ended with _LINKER_FLAGS in the CMakeCache.txt file (also available with Advanced checked in CMake GUI). Remove them, or change into /machine:X64.

Also, just after you generated the project for MSVC (if you fail or forget to do that before the first compiling, you'll have to delete and regenerate all project files) then open Configuration Manager exactly after generation from cmake and setup x86 platform with requesting to generate this for every subproject.

0
sarabandeCommented:
sorry Martin, i was too late ;-)

it was not intended by me to post the instructions a second time.

Sara
0
Redefining Cyber Security w/ AI & Machine Learning

The implications of AI and machine learning in cyber security are massive and constantly growing, creating both efficiencies and new challenges across the board. Join our webinar on Sept. 21st to learn more about leveraging AI and machine learning to protect your business.

mattibuttAuthor Commented:
hi
thanks for the replies problem is I have tried to follow through instructions and they don't work simply when i try configure perl it doesn't recognise the command however when i simply enquire about perl in cmd it does tell me its version.

seems like even if i do get the openssl and perl configured I don't understand how this project will be built using visual studio i have tried with 2012 and 2017.
thanks
0
mattibuttAuthor Commented:
perl error
0
mattibuttAuthor Commented:
control-panel.JPGI also have both openssl as well perl installed.
0
sarabandeCommented:
what are you doing with perl? it can't help to confuse the windows cmd shell with perl.

type 'dir' at c:\openssl-win64> prompt.

it is like an 'ls' command and shows the files and sub folders of the folder c:\openssl-win64

to change the folder to a sub folder named lib type 'cd lib'. to go back type 'cd ..'

or use the  explorer to find out whether the openssl build was successful. the folder openssl-win64 should contain .lib files and .dll files probably in subfolders named 'lib', 'bin' or 'dll'

post those files such that we could verify whether it was successful.

if so, you could proceed to build the pthread library.

Sara
0
mattibuttAuthor Commented:
ok now i have corrected the mistake and downloaded the correct ssl however when i run the command i don't see any folder created with dLL and if i re-enter command it says target already defined.
vs command prompt

perl Configure VC-WIN32 --prefix=C:\Build-OpenSSL-VC-32 ms\do_ms nmake -f ms\nt.mak  nmake -f ms\nt.mak install
0
sarabandeCommented:
can you open an explorer and take a screenshot of the opened tree at c:\openssl-1.0.2o


Sara
0
mattibuttAuthor Commented:
openssl-screen-shot.JPG
0
joinaunionCommented:
This walkthrough may be of some help.
https://msdn.microsoft.com/en-ca/library/ms235639.aspx
0
Martin MillerCTOCommented:
It seems like you need a combo of Linux capability also, e.g.  Did you install Cygwin ?

That's why the linux commands are not working... it's either not in path or installed.
0
mattibuttAuthor Commented:
I have indeed install CygWin however I don't see any environment variable exist for cygwin.

envrinoment-variable.JPG
thanks
0
Martin MillerCTOCommented:
What happens when you type these commands?  Specifically the ./configure command below... then make

Please share that command line output

mkdir build-cygwin

cd build-cygwin

 ../configure --prefix=install --cygwin-use-posix

 make

Open in new window

0
mattibuttAuthor Commented:
matti@MSI /cygdrive/c/srt-master/build-cygwin/build-cygwin
$ mkdir build-cygwin

matti@MSI /cygdrive/c/srt-master/build-cygwin/build-cygwin
$ cd build-cygwin

matti@MSI /cygdrive/c/srt-master/build-cygwin/build-cygwin/build-cygwin
$ ../configure --prefix=install --cygwin-use-posix
-bash: ../configure: No such file or directory

matti@MSI /cygdrive/c/srt-master/build-cygwin/build-cygwin/build-cygwin
$ make
-bash: make: command not found

matti@MSI /cygdrive/c/srt-master/build-cygwin/build-cygwin/build-cygwin
$
cygwin.JPG
0
mattibuttAuthor Commented:
i have deleted the folder and re-executed the command i get the following error.
matti@MSI ~
$ cd C:\srt-master

matti@MSI /cygdrive/c/srt-master
$ mkdir build-cygwin

matti@MSI /cygdrive/c/srt-master
$ cd build-cygwin

matti@MSI /cygdrive/c/srt-master/build-cygwin
$ ../configure --prefix=install --cygwin-use-posix
CYGWIN DETECTED
Running: cmake .. -DCMAKE_INSTALL_PREFIX=install -DCYGWIN_USE_POSIX=1
CONFIGURE: cmake reported error: couldn't execute "cmake": no such file or directory

matti@MSI /cygdrive/c/srt-master/build-cygwin
0
Martin MillerCTOCommented:
Seems like you are missing environment path setup for cygwin, both configure and make are their commands.

This link has some helpful info on Cygwin install, I think you are missing one or more paths.

Search your drives for 'make', and then add that path to "PATH".

If you don't find 'make' , then you are missing part of the cygwin installation. It might be 'make.cmd, or make.exe'.
0
mattibuttAuthor Commented:
how do i do that.
0
Martin MillerCTOCommented:
On windows, you can use file-explorer search for files.
0
mattibuttAuthor Commented:
when i search in cygwin folder i get tons of results for make file.
make.JPG
0
Martin MillerCTOCommented:
you want to find a folder called  'bin',  with make in it.. unfortunately I am on a MAC... but this is how make is found...

 which make
/usr/bin/make

do you have a c:/cygwin64/usr/bin folder, slashes may go in opposite direction for you :-)   c:\cygwin64\usr\bin

If not... you are missing build tools that are critical
0
mattibuttAuthor Commented:
$  which make
which: no make in (/usr/local/bin:/usr/bin:/cygdrive/c/Perl64/site/bin:/cygdrive/c/Perl64/bin:/cygdrive/c/ProgramData/Oracle/Java/javapath:/cygdrive/c/Program Files (x86)/Intel/iCLS Client:/cygdrive/c/Program Files/Intel/iCLS Client:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/DAL:/cygdrive/c/Program Files/Intel/Intel(R) Management Engine Components/DAL:/cygdrive/c/Program Files (x86)/Intel/Intel(R) Management Engine Components/IPT:/cygdrive/c/Program Files/Intel/Intel(R) Management Engine Components/IPT:/cygdrive/c/Program Files (x86)/NVIDIA Corporation/PhysX/Common:/cygdrive/c/Program Files/Intel/WiFi/bin:/cygdrive/c/Program Files/Common Files/Intel/WirelessCommon:/cygdrive/c/WINDOWS/system32:/cygdrive/c/WINDOWS:/cygdrive/c/WINDOWS/System32/Wbem:/cygdrive/c/WINDOWS/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program Files (x86)/QuickTime/QTSystem:/cygdrive/c/Program Files (x86)/Skype/Phone:/cygdrive/c/Cygwin/bin:/cygdrive/c/Users/matti/AppData/Local/Microsoft/WindowsApps:/usr/lib/lapack)
0
Martin MillerCTOCommented:
you are missing a path or build tools that are critical
0
mattibuttAuthor Commented:
do I uninstall cygwin and re-install?
0
Martin MillerCTOCommented:
Not sure about reinstall or is there a different distribution you need of cygwin. There is a critical part missing... you need the developer tools that should be included, such as 'make' .
0
sarabandeCommented:
you want to find a folder called  'bin',  with make in it..

- click at start button and type: cmd
  <Enter> starts a so-called dos box or better command window
- then type: c:  
  (always close with <Enter>). that brings you to c drive if not already there (what is likely)
- type: cd \  
  what brings you to the root directory
- type:
  dir /s make.*
  that shows you all files with filename 'make' and arbitrary extension.
   you should check whether any of the listed entries is make.com or make.exe where the path
   contains 'cygwin' and the parent folder is 'bin'.
- if found:
   + click at the icon in the top-left of your command window and choose properties
   + check Quick Edit and leave the properties window
   + now you can use the mouse to select the path where the cygwin make utility was in
   + <ENTER> will put the path into the clipboard
- if not found:
  +  you have to deinstall cygwin and reinstall.

note, any errors like file not found or unknown command always tell that the action you made was not successful. it doesn't make sense to continue as long as the error is not fixed.

and then add that path to "PATH"
if you found cygwin make you would add the path to the PATH environment variable.

for that
- open system settings (type: 'system settings' after clicking to the start button)
- goto system and security - system - advanced system properties - environment variables
- in the system variables you find Path. select it and click 'Edit' button.
- choose 'New' and paste the path from clipboard by CTRL+V
- close by OK

the new PATH now is available for any new program or shell you would open. it is not available in already opened programs like Visual Studio or a cygwin shell.

Sara
0
Martin MillerCTOCommented:
Checking in, did you get further with Cygwin ?
0
Martin MillerCTOCommented:
Can we close this question ?
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Windows OS

From novice to tech pro — start learning today.