Help Building FreeRDP

Discussion in 'Mac Programming' started by ArtOfWarfare, Apr 28, 2016.

  1. ArtOfWarfare macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #1
    Hi guys,

    I'm looking to make something kind of like an SSH client, except it'll control Windows using the RDP protocol (since it's extremely common for Windows Servers to have Remote Desktop enabled, but extremely rare for them to have an SSH server set up.) I figure I'll start with FreeRDP (an open source implementation of a Remote Desktop Client) and then make it so that when a connection is made, it automatically launch CMD and run whatever command you pass it, then it'll respond with the output and close the CMD session.

    Link to directions for compiling FreeRDP: https://github.com/FreeRDP/FreeRDP/wiki/Compilation

    So I've cloned it with git. I have CMake 3.5.2 installed. I tried running the command to compile it on Mac:

    Code:
    /Applications/CMake.app/contents/bin/cmake -D "CMAKE_OSX_ARCHITECTURES:STRING=x86_64" . && make
    And it spat out this:

    Code:
    -- Found PkgConfig: /usr/local/bin/pkg-config (found version "0.28") 
    -- FreeRDP GIT
    -- Git Revision bd7ed27
    -- Performing Test Wno-deprecated-declarations
    -- Performing Test Wno-deprecated-declarations - Success
    -- Performing Test Wno-deprecated-declarationsCXX
    -- Performing Test Wno-deprecated-declarationsCXX - Success
    -- Looking for include file fcntl.h
    -- Looking for include file fcntl.h - found
    -- Looking for include file unistd.h
    -- Looking for include file unistd.h - found
    -- Looking for include file execinfo.h
    -- Looking for include file execinfo.h - found
    -- Looking for include file inttypes.h
    -- Looking for include file inttypes.h - found
    -- Looking for include file sys/modem.h
    -- Looking for include file sys/modem.h - not found
    -- Looking for include file sys/filio.h
    -- Looking for include file sys/filio.h - found
    -- Looking for include file sys/sockio.h
    -- Looking for include file sys/sockio.h - found
    -- Looking for include file sys/strtio.h
    -- Looking for include file sys/strtio.h - not found
    -- Looking for include file sys/select.h
    -- Looking for include file sys/select.h - found
    -- Looking for include file syslog.h
    -- Looking for include file syslog.h - found
    -- Performing Test HAVE_TM_GMTOFF
    -- Performing Test HAVE_TM_GMTOFF - Success
    -- Looking for pthread.h
    -- Looking for pthread.h - found
    -- Looking for pthread_create
    -- Looking for pthread_create - found
    -- Found Threads: TRUE  
    -- Looking for pthread_mutex_timedlock in pthread
    -- Looking for pthread_mutex_timedlock in pthread - not found
    -- Looking for include file sys/eventfd.h
    -- Looking for include file sys/eventfd.h - not found
    -- Looking for include file sys/eventfd.h
    -- Looking for include file sys/eventfd.h - not found
    -- Looking for include file sys/timerfd.h
    -- Looking for include file sys/timerfd.h - not found
    -- Looking for include file poll.h
    -- Looking for include file poll.h - found
    -- Looking for ceill
    -- Looking for ceill - found
    -- Finding recommended feature libsystemd for systemd journal appender (allows to export wLog to systemd journal)
    --     Disable feature libsystemd using "-DWITH_LIBSYSTEMD=OFF"
    -- Could NOT find libsystemd (missing:  LIBSYSTEMD_LIBRARY LIBSYSTEMD_INCLUDE_DIR) 
    CMake Warning at cmake/FindFeature.cmake:46 (message):
          feature libsystemd was requested but could not be found! ON / FALSE
    Call Stack (most recent call first):
      CMakeLists.txt:642 (find_feature)
    
    
    -- Skipping optional feature X11 for X11 (X11 client and server)
    --     Enable feature X11 using "-DWITH_X11=ON"
    -- Skipping disabled feature Wayland for Wayland (Wayland client)
    -- Skipping disabled feature DirectFB for DirectFB (DirectFB client)
    -- Finding required feature ZLIB for compression (data compression)
    -- Found ZLIB: /usr/lib/libz.dylib (found version "1.2.5") 
    -- Finding required feature OpenSSL for cryptography (encryption, certificate validation, hashing functions)
    CMake Error at /Applications/CMake.app/Contents/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
      Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
      system variable OPENSSL_ROOT_DIR (missing: OPENSSL_INCLUDE_DIR)
    Call Stack (most recent call first):
      /Applications/CMake.app/Contents/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
      cmake/FindOpenSSL.cmake:317 (find_package_handle_standard_args)
      cmake/FindFeature.cmake:16 (find_package)
      CMakeLists.txt:674 (find_feature)
    
    
    -- Configuring incomplete, errors occurred!
    See also "/Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeOutput.log".
    See also "/Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeError.log".
    I can't tell - what's important here and what isn't? It says a lot of files aren't found, but then it continues... does that indicate that those files are optional and just some features won't be enabled, or are they important to have and that's why the build fails?

    The last one catches my attention, about it trying and failing to find OpenSSL. I'd guess it's pretty important and non-optional, since I know RDP encrypts all of its communications.

    I have OpenSSL installed... at least an executable. I can do

    Code:
    which openssl
    and it tells me I have it at /usr/bin/openssl

    Is that what this build script wants? Or is there some sort of library that I need to tell it about using the OPENSSL_ROOT_DIR environment variable?

    Then again, the CMakeError.log file makes me feel like OpenSSL isn't the reason my configuration failed, because there's no mention of it there.

    The contents of CMakeError.log:

    Code:
    Determining if files sys/modem.h exist failed with the following output:
    Change Dir: /Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeTmp
    
    Run Build Command:"/usr/bin/make" "cmTC_5e193/fast"
    /Applications/Xcode-beta.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_5e193.dir/build.make CMakeFiles/cmTC_5e193.dir/build
    Building C object CMakeFiles/cmTC_5e193.dir/CheckIncludeFiles.c.o
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc    -Wno-unused-parameter -Wno-unused-macros -Wno-padded -Wno-c11-extensions -Wno-gnu -Wno-deprecated-declarations -DWINPR_EXPORTS -DFREERDP_EXPORTS  -arch x86_64 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -fPIE   -o CMakeFiles/cmTC_5e193.dir/CheckIncludeFiles.c.o   -c /Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeTmp/CheckIncludeFiles.c
    /Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeTmp/CheckIncludeFiles.c:2:10: fatal error: 'sys/modem.h' file not found
    #include <sys/modem.h>
             ^
    1 error generated.
    make[1]: *** [CMakeFiles/cmTC_5e193.dir/CheckIncludeFiles.c.o] Error 1
    make: *** [cmTC_5e193/fast] Error 2
    
    Source:
    /* */
    #include <sys/modem.h>
    
    
    int main(void){return 0;}
    
    Determining if files sys/strtio.h exist failed with the following output:
    Change Dir: /Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeTmp
    
    Run Build Command:"/usr/bin/make" "cmTC_23450/fast"
    /Applications/Xcode-beta.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_23450.dir/build.make CMakeFiles/cmTC_23450.dir/build
    Building C object CMakeFiles/cmTC_23450.dir/CheckIncludeFiles.c.o
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc    -Wno-unused-parameter -Wno-unused-macros -Wno-padded -Wno-c11-extensions -Wno-gnu -Wno-deprecated-declarations -DWINPR_EXPORTS -DFREERDP_EXPORTS  -arch x86_64 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -fPIE   -o CMakeFiles/cmTC_23450.dir/CheckIncludeFiles.c.o   -c /Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeTmp/CheckIncludeFiles.c
    /Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeTmp/CheckIncludeFiles.c:2:10: fatal error: 'sys/strtio.h' file not found
    #include <sys/strtio.h>
             ^
    1 error generated.
    make[1]: *** [CMakeFiles/cmTC_23450.dir/CheckIncludeFiles.c.o] Error 1
    make: *** [cmTC_23450/fast] Error 2
    
    Source:
    /* */
    #include <sys/strtio.h>
    
    
    int main(void){return 0;}
    
    Determining if the function pthread_mutex_timedlock exists in the pthread failed with the following output:
    Change Dir: /Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeTmp
    
    Run Build Command:"/usr/bin/make" "cmTC_8c537/fast"
    /Applications/Xcode-beta.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_8c537.dir/build.make CMakeFiles/cmTC_8c537.dir/build
    Building C object CMakeFiles/cmTC_8c537.dir/CheckFunctionExists.c.o
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc    -Wno-unused-parameter -Wno-unused-macros -Wno-padded -Wno-c11-extensions -Wno-gnu -Wno-deprecated-declarations -DWINPR_EXPORTS -DFREERDP_EXPORTS -DCHECK_FUNCTION_EXISTS=pthread_mutex_timedlock -arch x86_64 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -fPIE   -o CMakeFiles/cmTC_8c537.dir/CheckFunctionExists.c.o   -c /Applications/CMake.app/Contents/share/cmake-3.5/Modules/CheckFunctionExists.c
    Linking C executable cmTC_8c537
    /Applications/CMake.app/Contents/bin/cmake -E cmake_link_script CMakeFiles/cmTC_8c537.dir/link.txt --verbose=1
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc   -Wno-unused-parameter -Wno-unused-macros -Wno-padded -Wno-c11-extensions -Wno-gnu -Wno-deprecated-declarations -DWINPR_EXPORTS -DFREERDP_EXPORTS -DCHECK_FUNCTION_EXISTS=pthread_mutex_timedlock -arch x86_64 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -Wl,-search_paths_first -Wl,-headerpad_max_install_names   CMakeFiles/cmTC_8c537.dir/CheckFunctionExists.c.o  -o cmTC_8c537  -lpthread 
    Undefined symbols for architecture x86_64:
      "_pthread_mutex_timedlock", referenced from:
          _main in CheckFunctionExists.c.o
    ld: symbol(s) not found for architecture x86_64
    clang: error: linker command failed with exit code 1 (use -v to see invocation)
    make[1]: *** [cmTC_8c537] Error 1
    make: *** [cmTC_8c537/fast] Error 2
    
    
    Determining if files sys/eventfd.h exist failed with the following output:
    Change Dir: /Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeTmp
    
    Run Build Command:"/usr/bin/make" "cmTC_eba47/fast"
    /Applications/Xcode-beta.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_eba47.dir/build.make CMakeFiles/cmTC_eba47.dir/build
    Building C object CMakeFiles/cmTC_eba47.dir/CheckIncludeFiles.c.o
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc    -Wno-unused-parameter -Wno-unused-macros -Wno-padded -Wno-c11-extensions -Wno-gnu -Wno-deprecated-declarations -DWINPR_EXPORTS -DFREERDP_EXPORTS  -arch x86_64 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -fPIE   -o CMakeFiles/cmTC_eba47.dir/CheckIncludeFiles.c.o   -c /Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeTmp/CheckIncludeFiles.c
    /Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeTmp/CheckIncludeFiles.c:2:10: fatal error: 'sys/eventfd.h' file not found
    #include <sys/eventfd.h>
             ^
    1 error generated.
    make[1]: *** [CMakeFiles/cmTC_eba47.dir/CheckIncludeFiles.c.o] Error 1
    make: *** [cmTC_eba47/fast] Error 2
    
    Source:
    /* */
    #include <sys/eventfd.h>
    
    
    int main(void){return 0;}
    
    Determining if files sys/eventfd.h exist failed with the following output:
    Change Dir: /Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeTmp
    
    Run Build Command:"/usr/bin/make" "cmTC_56f4d/fast"
    /Applications/Xcode-beta.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_56f4d.dir/build.make CMakeFiles/cmTC_56f4d.dir/build
    Building C object CMakeFiles/cmTC_56f4d.dir/CheckIncludeFiles.c.o
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc    -Wno-unused-parameter -Wno-unused-macros -Wno-padded -Wno-c11-extensions -Wno-gnu -Wno-deprecated-declarations -DWINPR_EXPORTS -DFREERDP_EXPORTS  -arch x86_64 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -fPIE   -o CMakeFiles/cmTC_56f4d.dir/CheckIncludeFiles.c.o   -c /Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeTmp/CheckIncludeFiles.c
    /Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeTmp/CheckIncludeFiles.c:2:10: fatal error: 'sys/eventfd.h' file not found
    #include <sys/eventfd.h>
             ^
    1 error generated.
    make[1]: *** [CMakeFiles/cmTC_56f4d.dir/CheckIncludeFiles.c.o] Error 1
    make: *** [cmTC_56f4d/fast] Error 2
    
    Source:
    /* */
    #include <sys/eventfd.h>
    
    
    int main(void){return 0;}
    
    Determining if files sys/timerfd.h exist failed with the following output:
    Change Dir: /Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeTmp
    
    Run Build Command:"/usr/bin/make" "cmTC_48ed0/fast"
    /Applications/Xcode-beta.app/Contents/Developer/usr/bin/make -f CMakeFiles/cmTC_48ed0.dir/build.make CMakeFiles/cmTC_48ed0.dir/build
    Building C object CMakeFiles/cmTC_48ed0.dir/CheckIncludeFiles.c.o
    /Applications/Xcode-beta.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc    -Wno-unused-parameter -Wno-unused-macros -Wno-padded -Wno-c11-extensions -Wno-gnu -Wno-deprecated-declarations -DWINPR_EXPORTS -DFREERDP_EXPORTS  -arch x86_64 -isysroot /Applications/Xcode-beta.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.11.sdk -fPIE   -o CMakeFiles/cmTC_48ed0.dir/CheckIncludeFiles.c.o   -c /Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeTmp/CheckIncludeFiles.c
    /Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeTmp/CheckIncludeFiles.c:2:10: fatal error: 'sys/timerfd.h' file not found
    #include <sys/timerfd.h>
             ^
    1 error generated.
    make[1]: *** [CMakeFiles/cmTC_48ed0.dir/CheckIncludeFiles.c.o] Error 1
    make: *** [cmTC_48ed0/fast] Error 2
    
    Source:
    /* */
    #include <sys/timerfd.h>
    
    
    int main(void){return 0;}
    So what do you guys think? What's important that I fix... and then how do I fix them?
     
  2. Osty macrumors 6502a

    Joined:
    Jul 15, 2008
    Location:
    Melbourne, AU
    #2
    Any reason why you are trying to build it instead of using the Home Brew package?
     
  3. Mernak macrumors 6502

    Joined:
    Apr 9, 2006
    Location:
    Kirkland, WA
    #3
    Okay, just glancing through since I'm just on my iPad, and the log snippet is kinda annoying to read. But the OpenSSL seems to be the main error here

    Try adding

    export OPENSSL_INCLUDE_DIR=/usr/bin

    To your .bashrc or .bash_profile, then re-sourcing it to pick up the changes in the current session

    source ~/.bashrc

    I'm guessing after that you might run into different errors, but it's one of those that you tend to have to fix them one at a time.

    The CMake "error" was a warning, not an actual error. It's possible it might not work as expected, but should be able to compile. You should be able to do something similar with which and set to get the correct directories. I'm guessing these environment variables are set on most Linux distros or something, I don't think I've come access them though.
     
  4. ArtOfWarfare thread starter macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #4
    Yes. I'd like to understand and modify it. Ultimately, I'm going to try turning it into a python library that allows for easily automating remote Windows machines, where the system administrator has allowed you to access it via RDP but not SSH (this probably describes the vast majority of Windows servers...)
     
  5. Osty macrumors 6502a

    Joined:
    Jul 15, 2008
    Location:
    Melbourne, AU
    #5

    Awesome, perfectly valid reason.

    If you turn it into a Python library are you planning to open source it?
     
  6. ArtOfWarfare, Apr 29, 2016
    Last edited: Apr 29, 2016

    ArtOfWarfare thread starter macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #6
    I don't know yet. It seems like this is going to involve a lot of work, and that it's going to result in a really useful product. I feel like I could try selling it. But then I'd have to set up a whole web store thing, and a lot fewer people would use it... also, how do you fairly price a library? Your library could be absolutely essential and the app it's part of useless without your library. Or your library could just be a finishing touch - not essential, but nice to have.

    So... haven't decided yet. Given I only ever finish around 10% of what I start, and I'm just getting started with this project, it's probably way too premature to think about how I want to ultimately distribute it.

    I am specifically going with FreeRDP instead of rdesktop because rdesktop's license is GPL 3 ("free as in useless", as I like to say) while FreeRDP's license is Apache, which is pretty easy to work with.

    ---
    Okay, I did that, but I still got errors about OpenSSL:

    Code:
    -- Finding required feature OpenSSL for cryptography (encryption, certificate validation, hashing functions)
    
    CMake Error at /Applications/CMake.app/Contents/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:148 (message):
    
      Could NOT find OpenSSL, try to set the path to OpenSSL root folder in the
    
      system variable OPENSSL_ROOT_DIR (missing: OPENSSL_INCLUDE_DIR)
    
    Call Stack (most recent call first):
    
      /Applications/CMake.app/Contents/share/cmake-3.5/Modules/FindPackageHandleStandardArgs.cmake:388 (_FPHSA_FAILURE_MESSAGE)
    
      cmake/FindOpenSSL.cmake:317 (find_package_handle_standard_args)
    
      cmake/FindFeature.cmake:16 (find_package)
    
      CMakeLists.txt:674 (find_feature)
    
    
    
    -- Configuring incomplete, errors occurred!
    
    See also "/Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeOutput.log".
    
    See also "/Users/Taylor/Dropbox/Programming/FreeRDP/CMakeFiles/CMakeError.log".
    I looked around line 317 of FindOpenSSL.cmake, and it looks like it tries to open a file ${OPENSSL_INCLUDE_DIR}/openssl/opensslv.h. If I have that file somewhere on my computer, it's definitely not under /usr/bin.

    Running find starting from / now, looking for that file...

    it looks like Unity's package includes a copy... as does each copy of Xcode...

    I think I'll just link against Unity's for now. I'm probably going to throw out the OpenSSL dependency later on. Right now I mostly just want to get a feel for what kinds of stuff I can do with FreeRDP, and find out how it communicates with a Windows machine to allow that.

    Edit:
    Ok... I think it's happy with my OPENSSL_INCLUDE_DIR now... but it also wants me to set OPENSSL_LIBRARIES, and maybe OPENSSL_ROOT_DIR, too?
     
  7. ArtOfWarfare thread starter macrumors 604

    ArtOfWarfare

    Joined:
    Nov 26, 2007
    #7
    Okay, scrap the idea of using whatever Unity has. I decided to just go ahead and install openssl with brew.

    I ran
    Code:
    brew install openssl
    That installed to /usr/local/opt/openssl

    Then I scrapped the idea of setting OPENSSL_INCLUDE_DIR and set OPENSSL_ROOT_DIR to /usr/local/opt/openssl

    And I think it worked... it ended the log messages with "Generating done" and it output a path that it wrote files to...
     
  8. displaced macrumors 65816

    displaced

    Joined:
    Jun 23, 2003
    Location:
    Gravesend, United Kingdom
    #8
    I reckon you'd be better off figuring out how tools like psexec provide a remote command prompt (of sorts).

    See (for example):
    https://blogs.technet.microsoft.com...using-psexec-to-open-a-remote-command-window/

    http://xcybercloud.blogspot.co.uk/2008/10/great-psexec-and-how-it-works.html

    I remember using (once upon a time) a psexec clone on Linux which successfully provided a remote command prompt to a Windows box from a Linux client.

    As is often the case, the Windows architecture is a lot more capable than the default set of tools MS decide to provide.

    EDIT: Ah, here we go -- it was called winexe:
    https://micksmix.wordpress.com/2012...like-client-for-accessing-windows-from-linux/

    If it wasn't gone midnight here, I'd see how easy it would be to port to BSD/OS X.
     
  9. teagls macrumors regular

    Joined:
    May 16, 2013
    #9

    FreeRDP is more then a command line tool though. It provides all the support systems for properly rendering and interacting with a remote windows UI. It's very easy to acquire the underlying drawable from a FreeRDP session and display it in say a custom OpenGL application. I've built it myself and it is a very good open source framework.
     
  10. AzN1337c0d3r macrumors 6502

    Joined:
    Sep 13, 2010
    #10
    Apple removed the headers for OpenSSL in the 10.11 SDK, they want everyone to use CommonCrypto. They left the lib and exe so everything that depended on it before still works but since there are no headers you can't compile anything against it unless you acquired it from other sources.
     

Share This Page