Use VS+VISUALGDB to compile the Linux version RCF (equivalent to Linux also has a COM version)

Source: Internet
Author: User
Tags win32

Read Catalogue

    • Configuring Items with wizards
    • Configuring the directory Structure
    • Modify project configuration
    • Add RCF source code
    • Complete the configuration and compile
    • Add a test program
    • Adding test code-communicating over TCP
    • Run the test program and view the test results
    • All makefile code generated by visualgdb

RPC Communication Framework--RCF the introduction of the RCF itself is to support cross-platform, its code on the Linux platform, can be through the GCC, make and other tools, compiled through.

Officially provided by the source code, only cmake compiled script, and did not provide makefile, if you want to use make compile directly, you must write your own makefile.

Aside from this, this article mainly introduces the compilation and debugging of the Linux version of the RCF library on Windows systems through VS and visualgdb.

Using VS+VISUALGDB to compile and debug Linux programs, the article has simply introduced the use of VISUALGDB, this article goes straight to the topic, introduces the method of compiling RCF static library.

Back to top configure items with wizards

When you create a project from a wizard, the following are some of the more important steps

Select the project type as a static library:

Share your code before Windows and Linux through Windows shared Folders and the SMB service:

The specific commands are:

Collapse
Mount.cifs//192.168.3.125/rcf.linux '/CODE/RCF '-o user=hbccdf,pass= ' * * * *, Noperm
Back to top configuration directory structure

The directory structure after configuration is as follows

Collapse
D:\CODE\C++\RCF. linux├─debug├─include│  ├─rcf│  │  ├─external│  │  │  └─asio│  │  │      └─asio│  │  │          ├─detail│  │  │  └─impl│  │  │          ├─impl│ │ │          ├─ip│ │ │  ├─detail│  │          │  │ │ └─impl│ │ │ │ └─impl│ │ │  ├─local│ │ │ │  └─detail│  │      │ │ └─impl│  │  │          ├─posix│  │  │          ├─ssl│ │ │ │  └─detail│  │          │ └─windows│  │  ├─test│  │  ├─thread│  │  │  └─impl│  │  ├─utf8│  │  │  └─detail│  │  └─util│  │      └─platform│  │          └─os│  │              ├─unix│  │              └─windows│  └─sf├─rcf.linux│  ├─debug│  │  └─rcf.linux.tlog│  ├─obj│  │  └─win32│  │      └─debug│  └─visualgdbcache│      └─rcf.linux-debug└─src    ├─rcf    │  ├─test    │  └─util    └─SF
Back to top Modify project configuration

Modify the project configuration through Visualgdb, that is, makefile related configuration, or you can directly change the text content via vs:

Back to top add RCF source code

Because the RCF source code is all contained in the RCF.cpp file, simply add the RCF.cpp file to vs:

Go back to the top to complete the configuration and compile

At this point, all the configurations have been completed and can be compiled with VS, and the following is the compile information:

Collapse
1>------started Build:  project: Rcf.linux, configuration: Debug Win32------1>  visualgdb:testing gkfx folder-based mapping d:\c Ode\c++\rcf.linux\rcf.linux <=> 192.168.3.128:/code/rcf/rcf.linux ... 1>  visualgdb:trying to create D:\code\c++\rcf.linux\rcf.linux\vgdb1889774204.tmp ... 1>  visualgdb:run ' make config=debug ' in directory '/code/rcf/rcf.linux ' on [email protected] (SSH) 1>  g++- Ggdb-ffunction-sections-o0  -I.. /include-ddebug-  C. /src/rcf/rcf.cpp-o debug/rcf.o-md-mf debug/rcf.dep1>  ar-r debug/librcf.a debug/rcf.o1>  ar:creating debug/librcf.a========== Generation:  success 1, failure 0, latest 0, skip 0 ==========
Back to top Add test program

Add the test program rcftest through the VISUALGDB Wizard,

Then configure the project:

Go back to the top add test code-communicate over TCP

RCF interprocess communication Demo program, which describes the steps of interprocess communication through RCF,

First add the interface I_hello:

Collapse
#pragma once#include "rcf/rcf.hpp" #include <iostream> #include <string>using namespace std; Rcf_begin (I_hello, "I_hello")    rcf_method_v1 (void, SayHello, const string&)    rcf_method_r1 (int, add, int &)    rcf_method_v0 (void, test) rcf_end (I_hello) class Helloimpl{public:    void SayHello (const string& World)    {        cout << ' Hello ' << world << Endl;    }    int Add (int& a)    {        A = a + A;        return a + 2;    }    void Test ()    {}};

Then add the test code:

Collapse
#include <iostream> #include "hello.h" using namespace Std;int main (int argc, char *argv[]) {    RCF:: Rcfinitdeinit Rcf_init;    Helloimpl Hello;    Rcf::rcfserver Server (Rcf::tcpendpoint (50001));    Server.bind<i_hello> (HELLO);    Server.start ();    Rcfclient<i_hello> Client (Rcf::tcpendpoint (50001));    String str = "Test";    Client. SayHello (str);    int a = 3;    int B = Client.add (a);    cout << "a =" << a << ", B =" << b << Endl;    for (int i = 0; i < 20000; ++i)    {        client.test ();    }    cout << "Done" << Endl;}

The following is the compilation information:

Collapse
1>------started Build:  project: rcftest, configuration: Debug Win32------1>  visualgdb:testing gkfx folder-based mapping D:\Cod E\c++\rcf.linux\rcftest <=> 192.168.3.128:/code/rcf/rcftest ... 1>  visualgdb:trying to create D:\code\c++\rcf.linux\rcftest\vgdb1568095730.tmp ... 1>  Updating d:\code\c++\rcf.linux\rcftest\makefile1>  visualgdb:updated source file list in d:\code\c++ \rcf.linux\rcftest\makefile. Enable verbose mode for more details.1>  visualgdb:run ' make config=debug ' in directory '/code/rcf/rcftest ' on [EMA Il protected] (SSH) 1>  g++-ggdb-ffunction-sections-o0-  I.. /include-ddebug-  c rcftest.cpp-o DEBUG/RCFTEST.O-MD-MF debug/rcftest.dep1>  g++-o debug/rcftest-wl,- Gc-sections   -L. /RCF.LINUX/DEBUG-WL,--start-group debug/rcftest.o-lrcf-lpthread-ldl  -wl,--rpath= ' $ORIGIN '   -wl,-- end-group========== Generation:  success 1, failure 0, latest 0, skip 0 ==========
Go back to the top run the test program and view the test results

You can view the results of the run with the VS F5 Debug run:

In this way, the work to compile the RCF through VS+VISUALGDB is complete.

Back to top visualgdb all the makefile code generated

Although on a Windows system, using VS for compilation development, you actually need to generate a makefile file and then compile it with make.

Each project generates several makefile files related to the project configuration, such as the Debug.mak file, and a configuration-independent file makefile, which, when compiled, selects the corresponding Debug.mak or Release.mak according to the configuration.

Rcf.linux Project

Debug.mak file:

Collapse
#Generated by Visualgdb (http://visualgdb.com) #DO not EDIT this FILE manually unless you absolutely need to#use visualgdb PROJECT PROPERTIES DIALOG Insteadbinarydir: = DEBUG#TOOLCHAINCC: = gcccxx: = g++ld: = $ (CXX) AR: = arobjcopy: = Objcopy#add Itional Flagspreprocessor_macros: = debuginclude_dirs: =. /includelibrary_dirs: = library_names: = pthreadadditional_linker_inputs: = Macos_frameworks: = LINUX_PACKAGES: = CFLAGS : =-ggdb-ffunction-sections-o0cxxflags: =-ggdb-ffunction-sections-o0asflags: = ldflags: =-Wl,-gc-sectionsCOMMONFLAG S: = Start_group: =-wl,--Start-groupend_group: =-WL,--end-group#additional Options detected from testing the Toolchainis _linux_project: = 1

Makefile File:

Collapse
#Generated by Visualgdb Project Wizard. #Note: Visualgdb would automatically update this file is the add new sources to the project. #All Other changes n This file would be preserved. #Visit http://visualgdb.com/makefiles for more details#visualgdb:autosourcefiles #&l t;---Remove the Disable auto-updating of SOURCEFILES and external_libstargetname: = Librcf.a#targettype can be a  PP, STATIC or sharedtargettype: = Staticto_lowercase = $ (subst a,a,$ (subst b,b,$ (subst c,c,$ (subst d,d,$ (subst e,e,$ f,f,$ (subst g,g,$ (subst h,h,$ (subst i,i,$ (subst j,j,$ (subst k,k,$ (subst l,l,$ (subst m,m,$ (subst n,n,$ (subst o,o,$ p,p,$ (subst q,q,$ (subst r,r,$ (subst s,s,$ (subst t,t,$ (subst u,u,$ (subst v,v,$ (subst w,w,$ (subst x,x,$ (subst y,y,$ (z,z,$1)))))))))) ())))) ())))) ())))))))) Makinclude $ (configuration_flags_file) include $ (additional_make_files) ifeq ($ (binarydir),) Error: $ (Error Invalid Configuration, please check your inputs) Endifsourcefiles: =. /src/rcf/rcf.cppexternal_libs: = external_libs_copied: = $ (foreach lib, $ (external_libs), $ (Binarydir)/$ (Notdir $ (LIB) )) CFLAGS + = $ (commonflags) Cxxflags + $ (commonflags) Asflags + = $ (commonflags) Ldflags + = $ (commonflags) CFLAGS + = $ ( addprefix-i,$ (include_dirs)) Cxxflags + = $ (addprefix-i,$ (include_dirs)) CFLAGS + = $ (addprefix-d,$ (preprocessor_ MACROS)) Cxxflags + = $ (addprefix-d,$ (Preprocessor_macros)) Asflags + = $ (addprefix-d,$ (Preprocessor_macros)) CXXFLAGS + = $ (addprefix-framework, $ (macos_frameworks)) CFLAGS + = $ (addprefix-framework, $ (macos_frameworks)) Ldflags + = $ ( Addprefix-framework, $ (macos_frameworks)) Ldflags + = $ (addprefix-l,$ (library_dirs)) ifeq ($ (generate_map_file), 1) Ldflags + =-wl,-map=$ (binarydir)/$ (basename $ (TARGETNAME)). Mapendiflibrary_ldflags = $ (addprefix-l,$ (library_names) ) ifeq ($ (is_linux_project), 1) Rpath_prefix: =-wl,--rpath= ' $ $ORIGIN/... /Library_ldflags + = $ (external_libs) Library_ldflags +-wl,--RPATh= ' $ $ORIGIN ' library_ldflags + $ (addsuffix ', $ (Addprefix $ (rpath_prefix), $ (dir $ (external_libs)))) Ifeq ($ (TAR GETTYPE), SHARED) CFLAGS + =-fpic cxxflags +-fpic asflags + =-fpic Library_ldflags + =-wl,-so name,$ (TARGETNAME) endif ifneq ($ (linux_packages),) Package_cflags: = $ (foreach pkg,$ (linux_packages), $ (s Hell Pkg-config--cflags $ (pkg)) Package_ldflags: = $ (foreach pkg,$ (linux_packages), $ (Shell pkg-config--libs $ (PK    g))) CFLAGS + = $ (package_cflags) Cxxflags + = $ (package_cflags) Library_ldflags + = $ (package_ldflags) endif Else Library_ldflags + = $ (external_libs) Endiflibrary_ldflags + = $ (additional_linker_inputs) All_make_files: = $ (FirstWord $ (makefile_list)) $ (configuration_flags_file) $ (additional_make_files) ifeq ($ (startupfiles),) All_ Source_files: = $ (SOURCEFILES) Else all_source_files: = $ (startupfiles) $ (filter-out $ (startupfiles), $ (SOURCEFILES)) ENDIFSOURCE_OBJ1: = $ (All_source_fiLES:.CPP=.O) Source_obj2: = $ (SOURCE_OBJ1:.C=.O) Source_obj3: = $ (SOURCE_OBJ2:.S=.O) Source_obj4: = $ (source_obj3:. S=.O) Source_obj5: = $ (SOURCE_OBJ4:.CC=.O) Source_objs: = $ (SOURCE_OBJ5:.CXX=.O) All_objs: = $ (Addprefix $ (BINARYDIR)/, $ (Notdir $ (SOURCE_OBJS))) Primary_outputs: =ifeq ($ (generate_bin_file), 1) primary_outputs + = $ (binarydir)/$ (basename $ (TARGETNAME)). Binendififeq ($ (generate_ihex_file), 1) primary_outputs + = $ (binarydir)/$ (basename $ (TARGETNAME)). Ihexendififeq ($ ( primary_outputs),) Primary_outputs: = $ (Binarydir)/$ (TARGETNAME) Endifall: $ (primary_outputs) $ (binarydir)/$ ( BaseName $ (TARGETNAME)). Bin: $ (binarydir)/$ (TARGETNAME) $ (objcopy)-o binary $< [email protected]$ (Binarydir) /$ (basename $ (TARGETNAME)). Ihex: $ (binarydir)/$ (TARGETNAME) $ (objcopy)-O ihex $< [Email protected]ifeq ($ (TAR GETTYPE), APP) $ (binarydir)/$ (TARGETNAME): $ (ALL_OBJS) $ (external_libs) $ (LD)-O [email protected] $ (ldflags) $ ( Start_group) $ (ALL_OBJS) $ (library_ldflags) $ (end_group) endififEQ ($ (TARGETTYPE), SHARED) $ (binarydir)/$ (TARGETNAME): $ (ALL_OBJS) $ (external_libs) $ (LD)-shared-o [email  Protected] $ (ldflags) $ (start_group) $ (ALL_OBJS) $ (library_ldflags) $ (end_group) endif ifeq ($ (TARGETTYPE), STATIC) $ ( Binarydir)/$ (TARGETNAME): $ (ALL_OBJS) $ (AR)-R [email protected] $^endif-include $ (ALL_OBJS:.O=.DEP) Clean:ifeq ( $ (Use_del_to_clean), 1) del/s/q $ (binarydir) Else RM-RF $ (binarydir) endif$ (binarydir): mkdir $ (binarydir) #Visual Gdb:filespecifictemplates #<---Visualgdb would use the following lines to define rules for source files in Subd irectories$ (Binarydir)/%.O:%.cpp $ (all_make_files) |$ (binarydir) $ (CXX) $ (cxxflags)-C $<-O [email protected ]-MD-MF $ (@:.o=.dep) $ (binarydir)/%.O:%.C $ (all_make_files) |$ (binarydir) $ (CC) $ (CFLAGS)-C $<-O [email pr Otected]-MD-MF $ (@:.o=.dep) $ (binarydir)/%.O:%. S $ (all_make_files) |$ (binarydir) $ (CC) $ (CFLAGS) $ (asflags)-C $<-o [email protected]-MD-MF $ (@:. O=.dep) $ (binarydir)/%.O:%.s $ (all_make_files) |$ (binarydir) $ (CC) $ (CFLAGS) $ (asflags)-C $<-O [Email prot  Ected]-MD-MF $ (@:.o=.dep) $ (binarydir)/%.O:%.cc $ (all_make_files) |$ (binarydir) $ (CC) $ (CFLAGS) $ (cxxflags)-C $<  -O [email protected]-md-mf $ (@:.o=.dep) $ (binarydir)/%.O:%.cxx $ (all_make_files) |$ (binarydir) $ (CC) $ (CFLAGS)  $ (cxxflags)-C $<-o [email protected]-md-mf $ (@:.o=.dep) #VisualGDB: generatedrules #<---All Lines below is auto-generated$ (Binarydir)/RCF.O:.. /src/rcf/rcf.cpp $ (all_make_files) |$ (binarydir) $ (CXX) $ (cxxflags)-C $<-o [email protected]-md-mf $ (@:.o=. Dep

Rcftest Project:

Collapse
#Generated by Visualgdb (http://visualgdb.com) #DO not EDIT this FILE manually unless you absolutely need to#use visualgdb PROJECT PROPERTIES DIALOG Insteadbinarydir: = DEBUG#TOOLCHAINCC: = gcccxx: = g++ld: = $ (CXX) AR: = arobjcopy: = Objcopy#add Itional Flagspreprocessor_macros: = debuginclude_dirs: =. /includelibrary_dirs: =. /rcf.linux/debuglibrary_names: = RCF pthread dladditional_linker_inputs: = macos_frameworks: = linux_packages: = CFLAGS:  =-ggdb-ffunction-sections-o0cxxflags: =-ggdb-ffunction-sections-o0asflags: = ldflags: =-Wl,-gc-sectionsCOMMONFLAGS : = Start_group: =-wl,--Start-groupend_group: =-WL,--end-group#additional Options detected from testing the Toolchainis_ Linux_project: = 1

Makefile File:

The makefile file with the Rcf.linux project is basically the same, not listed here.

Http://www.cnblogs.com/hbccdf/p/use_vs_and_visualgdb_build_rcf.html

Use VS+VISUALGDB to compile the Linux version RCF (equivalent to Linux also has a COM version)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.