How can i Linking the Protocol Buffer(C++) into the Xcode - hyperlink

I added the protobuf class "xxx.pb.h","xxx.pb.cc" in Project.
I added a path"/usr/local/include" in Header Search Paths,
and added a path"/usr/local/lib" in Library Search Paths.
Now I encountered a problem,
The following error at Build:
ld: warning: ignoring file /usr/local/lib/libprotobuf.dylib, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): /usr/local/lib/libprotobuf.dylib
ld: warning: ignoring file /usr/local/lib/libprotoc.dylib, file was built for unsupported file format ( 0xcf 0xfa 0xed 0xfe 0x 7 0x 0 0x 0 0x 1 0x 3 0x 0 0x 0 0x 0 0x 6 0x 0 0x 0 0x 0 ) which is not the architecture being linked (i386): /usr/local/lib/libprotoc.dylib
Undefined symbols for architecture i386:
"google::protobuf::DescriptorPool::generated_pool()", referenced from:
protobuf_AssignDesc_person_2eproto() in person.pb.o
"google::protobuf::DescriptorPool::InternalAddGeneratedFile(void const*, int)", referenced from:
protobuf_AddDesc_person_2eproto() in person.pb.o
"google::protobuf::MessageFactory::generated_factory()", referenced from:
protobuf_AssignDesc_person_2eproto() in person.pb.o
...
...
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"vtable for google::protobuf::Message", referenced from:
google::protobuf::Message::Message() in person.pb.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Image

Follow the steps mentioned in this answer -> https://stackoverflow.com/a/10279656/1383704
There are a few pitfalls here and there, for which you may check my own answer for the same qn.
These were the steps I followed differently
instead of giving header search path till google directory, i gave the search path till the "src/" directory
In whichever you import your xxx.pb.h you have to rename the .m to .mm
In Xcode 4.5 i was still getting some linker errors :
symbols not found for architecture i386
Because of this I wasn't able to run on simulator. But the code will run on actual device.

Related

How to place printer driver parameters in postscript print file?

i have a postscript file, which has heavily printer driver setting dependencies. I am trying to bundle printer settings into my postscript printfile and passthrough it to the printer. The passthrough works just fine with `lpr -l . But i am not able to bring some options from the ppd directly into the postscript file.
Xerox pdd file snipped
*OpenUI *OutputMode/Print Quality: PickOne
*OrderDependency: 46.0 AnySetup *OutputMode
*DefaultOutputMode: HighSpeed
*OutputMode HighSpeed/High Speed: "
<</PostRenderingEnhance true
/PostRenderingEnhanceDetails currentpagedevice
1 index get 1 dict copy
dup /Type 33 put
dup /OutputMode (high-speed) put
>> setpagedevice
"
*End
*OutputMode HighQuality/High Quality: "
<</PostRenderingEnhance true
/PostRenderingEnhanceDetails currentpagedevice
1 index get 1 dict copy
dup /Type 33 put
dup /OutputMode (highest-quality) put
>> setpagedevice
"
*End
*OutputMode HighResolution/High Resolution: "
<</PostRenderingEnhance true
/PostRenderingEnhanceDetails currentpagedevice
1 index get 1 dict copy
dup /Type 33 put
dup /OutputMode (highest-resolution) put
>> setpagedevice
"
*End
*CloseUI: *OutputMode
When i place the highest-resolution part at the beginning of the %%BeginPrelog part, than i get an invalid file:
<</PostRenderingEnhance true
/PostRenderingEnhanceDetails currentpagedevice
1 index get 1 dict copy
dup /Type 33 put
dup /OutputMode (highest-resolution) put
>> setpagedevice
When i evaluate the correctness of the file via ps2pdf i get the following error:
Error: /undefined in --get--
Operand stack:
--nostringval-- PostRenderingEnhance true PostRenderingEnhanceDetails --dict:210/309(ro)(L)-- PostRenderingEnhanceDetails
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1990 1 3 %oparray_pop 1989 1 3 %oparray_pop 1977 1 3 %oparray_pop 1833 1 3 %oparray_pop --nostringval-- %errorexec_pop .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval--
Dictionary stack:
--dict:731/1123(ro)(G)-- --dict:0/20(G)-- --dict:75/200(L)--
Current allocation mode is local
Current file position is 308
GPL Ghostscript 9.50: Unrecoverable error, exit code 1
Nevertheless, the setpagedevice options from this post works just fine:
How to select PostScript printer output tray
So i do not know how to convert the ppd option to valid postscript code. Does anyone have a clue here, how to get a valid postscript file?
You are trying to apply a device-specific control (/OutputMode) to a device which does not support that control. Not only that, but the code you include acesses the current page device dictionary and assumes that there will be a PostRenderingEnhanceDetails dictionary in it. The code makes no attempt to check if the required data exists which means it will only work on a device which has a /PostRenderingEnhanceDetails entry in the page device dictionary. The pdfwrite device (which is what ps2pdf uses) does not have such an entry, which is why you get an error.
There may be nothing wrong with your PostScript, its simply that you can't apply it to that device. Note that all the keys in the question you link to are standard page device dictionary entries, OutputMode is not and there is no PostRenderingEnhanceDetails entry either.
The PostScript code in the PPD (PostScript Printer Description) is all that you need to use, but the opint of a PPD is to include PostScript that will only work reliably on the printer its intended for. You can't use Ghostscript to test the correctness of device-specific PostScript configured for a non-Ghostscript device.

Error on convert pdf to png using ImageMagick

Give error while convert pdf to png by using below command :
convert -density 300 -depth 8 -quality 85 655382767_1460008284.pdf[0-9] 655382767_1460008284.png
OS : Redhat 64 bit 6.7
ImageMagick : version 6.7.2-7 2015-02-27 Q16
Ghostscript : GPL Ghostscript 8.70 (2009-07-31)
Its give below error :
+++++++++++++++++++++++++++++++++
Error: /ioerror in --showpage--
Operand stack:
1 true
Execution stack:
%interp_exit .runexec2 --nostringval-- --nostringval-- --nostringval-- 2 %stopped_push --nostringval-- --nostringval-- --nostringval-- false 1 %stopped_push 1862 1 3 %oparray_pop 1861 1 3 %oparray_pop 1845 1 3 %oparray_pop --nostringval-- --nostringval-- 4 1 8 --nostringval-- %for_pos_int_continue --nostringval-- --nostringval-- 1745 0 9 %oparray_pop --nostringval-- --nostringval--
Dictionary stack:
--dict:1157/1684(ro)(G)-- --dict:1/20(G)-- --dict:75/200(L)-- --dict:75/200(L)-- --dict:106/127(ro)(G)-- --dict:286/300(ro)(G)-- --dict:22/25(L)-- --dict:4/6(L)-- --dict:27/40(L)--
Current allocation mode is local
Last OS error: 28
GPL Ghostscript 8.70: Unrecoverable error, exit code 1
convert: Postscript delegate failed 655382767_1460008284.pdf': No such file or directory # error/pdf.c/ReadPDFImage/664. convert: missing an image filename655382767_1460008284.png' # error/convert.c/ConvertImageCommand/3015.
++++++++++++++++++++++++++++++++++
Please help me to fix it.
Also some other pdf files are converted perfactly to png.
Please find attachment of pdf file which are making issue on converting to png using Imagemagick convert command.
enter link description here
ioerror means there was an I/O error, which may mean that the disk is full, or there was some other problem. Try using a lower resolution ('density' in IM terms I think). Given that you have 8 pages, each page is 32x76 inches and you have a resolution of 300 dpi you are looking at producing a lot of data, about 1.8Gb if depth=8 means greyscale.
There could be any number of other reasons why there was an ioerror, the next thing to do is to try a more recent version of Ghostscript 8.70 is now 6 years old..... As Mark Setchell suggests you could also try using a more recent version of ImageMagick, though I doubt that will help, since its clearly an error being returned from Ghostscript.

iOS application fails to archive for distribution

My application builds, runs, simulates etc. etc. fine! Everything works 100% on both the simulators and physical devices. No errors or warnings during building.
Now, when I try to archive my project, I get the following error:
0 clang 0x000000010bdb3472 _ZL15PrintStackTracePv + 34
1 clang 0x000000010bdb38f9 _ZL13SignalHandleri + 553
2 libsystem_c.dylib 0x00007fff8bd8ccfa _sigtramp + 26
3 libsystem_c.dylib 0x0000000000000001 _sigtramp + 18446603338169922337
4 clang 0x000000010bc7fbbf (anonymous namespace)::ObjCARCOpt::runOnFunction(llvm::Function&) + 7407
5 clang 0x000000010b0502b2 llvm::FPPassManager::runOnFunction(llvm::Function&) + 322
6 clang 0x000000010b052baf (anonymous namespace)::CGPassManager::runOnModule(llvm::Module&) + 1039
7 clang 0x000000010b050bc1 llvm::MPPassManager::runOnModule(llvm::Module&) + 289
8 clang 0x000000010b0505c5 llvm::PassManagerImpl::run(llvm::Module&) + 277
9 clang 0x000000010b0504ad llvm::PassManager::run(llvm::Module&) + 13
10 clang 0x000000010b02f0e8 clang::EmitBackendOutput(clang::DiagnosticsEngine&, clang::CodeGenOptions const&, clang::TargetOptions const&, clang::LangOptions const&, llvm::Module*, clang::BackendAction, llvm::raw_ostream*) + 4424
11 clang 0x000000010b02c941 clang::BackendConsumer::HandleTranslationUnit(clang::ASTContext&) + 513
12 clang 0x000000010aef83f6 clang::ParseAST(clang::Sema&, bool) + 406
13 clang 0x000000010aef6ed7 clang::CodeGenAction::ExecuteAction() + 855
14 clang 0x000000010aec943f clang::CompilerInstance::ExecuteAction(clang::FrontendAction&) + 879
15 clang 0x000000010aec80cb clang::ExecuteCompilerInvocation(clang::CompilerInstance*) + 2683
16 clang 0x000000010aeba8ce cc1_main(char const**, char const**, char const*, void*) + 5086
17 clang 0x000000010ae950d8 main + 648
18 clang 0x000000010ae94e44 start + 52
clang: error: unable to execute command: Segmentation fault: 11
clang: error: clang frontend command failed due to signal 2 (use -v to see invocation)
clang: note: diagnostic msg: Please submit a bug report to http://developer.apple.com/bugreporter/ and include command line arguments and all diagnostic information.
clang: note: diagnostic msg: Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /var/folders/yn/jhqtwmzx2l31sytjj7ltz_qc0000gn/T/Image-u5GlrW.mii
clang: note: diagnostic msg: /var/folders/yn/jhqtwmzx2l31sytjj7ltz_qc0000gn/T/Image-u5GlrW.sh
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 254
and I have no idea why. I now the problem comes from Image.mm that I am using from the simple-iphone-image-processing project. And I think it has to do with ARC. Can anyonw shed some more light on this?
Thanks
UPDATE
OK, so I just tried it a bunch of times and it worked. So the problem is intermittent. I'm leaving this question here if anyone else maybe has something to say.
The function that is breaking is ObjCARCOpt::runOnFunction(llvm::Function&). Just for giggles, I posted the runOnFunction() code below. The purpose of this function is to optimize ARC-related object code in the llvm::Function object that is passed in. That's fine, but there seems to be a bug in the compiler related to Objective-C++ handling, which frankly doesn't surprise me.
Bug reports have already been submitted to Apple (here, here, probably other places). You should report it too.
Until then, there are a few things I might suggest.
1) Since the problem is intermittent, just get on with your project. This could work out for you, or maybe not. After all, compilers are supposed to be deterministic...
2) Try to turn off ARC for your Obj-C++ stuff. This is probably the simplest way.
3) Turn off ARC optimizations. Do this by omitting -enable-objc-arc-opts from your build. How to do this using XCode build settings is left as an exercise for the reader. Anyway I think your best bet is 2).
Code from llvm-3.0.src/lib/Transforms/Scalar/ObjCARC.cpp is below. Your best bet is to get out at if (!Run) return false;. Run will be false if ARC is disabled in the module being parsed. Good luck, don't forget to submit that bug report!
bool ObjCARCOpt::runOnFunction(Function &F) {
if (!EnableARCOpts)
return false;
// If nothing in the Module uses ARC, don't do anything.
if (!Run)
return false;
Changed = false;
PA.setAA(&getAnalysis<AliasAnalysis>());
// This pass performs several distinct transformations. As a compile-time aid
// when compiling code that isn't ObjC, skip these if the relevant ObjC
// library functions aren't declared.
// Preliminary optimizations. This also computs UsedInThisFunction.
OptimizeIndividualCalls(F);
// Optimizations for weak pointers.
if (UsedInThisFunction & ((1 << IC_LoadWeak) |
(1 << IC_LoadWeakRetained) |
(1 << IC_StoreWeak) |
(1 << IC_InitWeak) |
(1 << IC_CopyWeak) |
(1 << IC_MoveWeak) |
(1 << IC_DestroyWeak)))
OptimizeWeakCalls(F);
// Optimizations for retain+release pairs.
if (UsedInThisFunction & ((1 << IC_Retain) |
(1 << IC_RetainRV) |
(1 << IC_RetainBlock)))
if (UsedInThisFunction & (1 << IC_Release))
// Run OptimizeSequences until it either stops making changes or
// no retain+release pair nesting is detected.
while (OptimizeSequences(F)) {}
// Optimizations if objc_autorelease is used.
if (UsedInThisFunction &
((1 << IC_Autorelease) | (1 << IC_AutoreleaseRV)))
OptimizeReturns(F);
return Changed;
}

XNA curve import from Maya?

I am trying to import a movement curve from Maya into my XNA game, but I cannot figure out how. Basically I want to catch the curve by it's name, and look up its values at different points of time.
Are curves exported into FBX at all? And, if not, then how to catch it?
Edit: Maya can export to Maya ASCII, and I tried to parse it, but I am not sure what formula I should use to recreate the curve.
Here is a Maya ASCII segment defining a typical curve:
createNode transform -name "curve1";
createNode nurbsCurve -name "curveShape1" -parent "curve1";
setAttr -keyable off ".visibility";
setAttr ".cached" -type "nurbsCurve"
3 11 0 no 3
16 0 0 0 1 2 3 4 5 6 7 8 9 10 11 11 11
14
-4.9774564508407968 0 -6.8331005825440476
-5.5957526204336077 0 -5.5944567905896161
-6.8323449596191823 0 -3.1171692066807277
-5.6935230034445992 0 3.3047128765440847
-1.6528787527978079 0 8.8676235621397499
7.5595909161095838 0 10.325347443191644
9.2297347448508607 0 8.5586791722955731
10.0730315036276 0 0.93412333819133941
5.9770106513247976 0 3.7809964481624871
2.9006817236214149 0 -3.3327711853359037
11.373191256465434 0 -4.6672854260704906
4.5697574985247682 0 -14.178349348937205
2.4191279569332935 0 -11.415532638650156
1.3438131861375628 0 -10.034124283506653
;
I managed to find the file format reference somewhere, the important info here is the knot indexes (16 0 0 0 1 2 3 4 5 6 7 8 9 10 11 11 11) and the coordinates (all lines containing three numbers).
But, I still have no idea how to recreate the curve. I googled a lot for nurbscurves, bsplines etc, but could not successfully match the result in Maya with any code I could find.
I've achieved this in 3dsmax by exporting the curve in Ascii format and parsing the text manually, does Maya have any such exporter?

Finding the type of data in IPv4 packet

Excluding options field in IPv4 header, after 20 bytes of header, data follows. That data may be TCP packet, or UDP etc.
Now given a IPv4 packet (with header and data), How to find out which type of transport layer packet (TCP/UDP/etc.) is present in data? Actually I am parsing a IPv4 packet so I need to understand this.
The protocol field of the IPv4 header (see RFC791) will tell you:
0 1 2 3
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
|Version| IHL |Type of Service| Total Length |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Identification |Flags| Fragment Offset |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Time to Live | Protocol | Header Checksum |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Source Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Destination Address |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
| Options | Padding |
+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
The protocol numbers are assigned by IANA and are listed here:
http://www.iana.org/assignments/protocol-numbers/protocol-numbers.xhtml
Some example protocol numbers are:
1 ICMP
6 TCP
17 UDP
Deep packet inspection? Ipoque release some open source code for this task: opendpi.

Resources