Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

386
Views
How to create C++ package using Swift Package Manager?

I'm following this blog to make a C++ package using SPM: http://ankit.im/swift/2016/05/21/creating-objc-cpp-packages-with-swift-package-manager/

But am getting this error when building:

swift build
'SwiftCpp' /home/karthik/Swift_programs/SwiftCpp: error: target at '/home/karthik/Swift_programs/SwiftCpp/Sources' contains mixed language source files; feature not supported

I'm using Swift version 4.2.3 on Ubuntu 18.04 LTS.

Here's the code :

main.cpp

#include <iostream>
#include "cpplib.h"

int main() {
    std::cout << cpplib::five();
    return 0;
}

cpplib.cpp

#include "include/cpplib.h"

namespace cpplib {
  int five(){
    return 5;
  }
}

cpplib.h

namespace cpplib{
  int five();
}

cwrapper.cpp

#include "include/cwrapper.h"
#include "cpplib.h"

int cwrapperfive(){
  return cpplib::five();
}

cwrapper.h

#ifdef __cplusplus
extern "C"  {
#endif

int cwrapperfive();

#ifdef __cplusplus
}
#endif

main.swift

import cwrapper
print(cwrapperfive())

How can I solve this?

over 4 years ago · Santiago Trujillo
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!